Exemplo n.º 1
0
 def func(self, *args):
     exc = ExceptionInfo()
     args = [self] + list(args) + [exc]
     res = fun(*args)
     if not res:
         raise ImageMagickException(exc)
     return Image(res)
Exemplo n.º 2
0
 def compare(self, other, metric):
     dbl = (ctypes.c_double * 1)()
     exp = ExceptionInfo()
     img = CompareImageChannels(self, other, ChannelType.All, metric, dbl,
                                exp)
     if not img:
         raise ImageMagickException(exp)
     return (dbl[0], Image(img))
Exemplo n.º 3
0
 def __enter__(self):
     exc = ExceptionInfo()
     px = lib.GetAuthenticPixels(self.im, self.x, self.y, self.w, self.h,
                                 exc)
     if not px:
         raise ImageMagickException(exc)
     self.px = ctypes.cast(px,
                           ctypes.POINTER(PixelPacket * (self.w * self.h)))
     return self
Exemplo n.º 4
0
 def ping(C, file):
     if isinstance(file, str):
         inf = ImageInfo()
         inf.filename = file
         exinfo = ExceptionInfo()
         res = lib.PingImage(inf, exinfo)
         if not res:
             raise ImageMagickException(exinfo)
         return C(res)
     else:
         raise NotImplementedError
Exemplo n.º 5
0
 def copyPixels(self, source, sx, sy, w, h, tx, ty):
     exc = ExceptionInfo()
     dest = lib.GetAuthenticPixels(self, tx, ty, w, h, exc)
     if not dest:
         raise ImageMagickException(exc)
     src = lib.GetAuthenticPixels(source, sx, sy, w, h, exc)
     if not src:
         raise ImageMagickException(exc)
     artype = ctypes.POINTER(PixelPacket * (w * h))
     artype1 = PixelPacket * (w * h)
     dest = ctypes.cast(dest, artype)
     src = ctypes.cast(src, artype)
     for i in range(w * h):
         dest[0][i] = src[0][i]
     if not lib.SyncAuthenticPixels(self, exc):
         raise ImageMagickException(exc)
Exemplo n.º 6
0
 def tile(C, file, width, height):
     if isinstance(file, str):
         inf = ImageInfo()
         file = 'tile:' + file
         inf.size = "%dx%d" % (width, height)
         inf.filename = file
         try:
             exinfo = ExceptionInfo()
             res = lib.ReadImage(inf, exinfo)
             if not res:
                 raise ImageMagickException(exinfo)
             return C(res)
         finally:
             inf.size = 0
             inf.file = 0
     else:
         raise NotImplementedError
Exemplo n.º 7
0
 def copy(self):
     exc = ExceptionInfo()
     res = lib.CloneImage(self, 0, 0, True, exc)
     if not res:
         raise ImageMagickException(exc)
     return Image(res)
Exemplo n.º 8
0
 def __exit__(self, A, B, C):
     del self.px
     exc = ExceptionInfo()
     lib.SyncAuthenticPixels(self.im, exc)
     del self.im