This commit is contained in:
Kovid Goyal 2012-10-23 08:20:01 +05:30
parent 5d3418f22c
commit 7a89cfe702

View File

@ -23,16 +23,16 @@ class Severity(ctypes.c_long):
pass pass
class String(ctypes.c_char_p): class String(ctypes.c_char_p):
def __del__(self): def __del__(self):
_libwand.MagickRelinquishMemory(self) _libwand.MagickRelinquishMemory(self)
def __str__(self): def __str__(self):
return self.value return self.value
if _libwand is not None: if _libwand is not None:
_libwand.MagickGetException.argtypes = [ctypes.c_void_p, ctypes.POINTER(Severity)] _libwand.MagickGetException.argtypes = [ctypes.c_void_p, ctypes.POINTER(Severity)]
_libwand.MagickGetException.restype = String _libwand.MagickGetException.restype = String
def get_exception(wand): def get_exception(wand):
severity = Severity() severity = Severity()
@ -52,4 +52,4 @@ def convert(source, dest):
if not _libwand.MagickWriteImage(wand, dest): if not _libwand.MagickWriteImage(wand, dest):
raise WandException('Cannot write image to file %s: %s'%(source, get_exception(wand))) raise WandException('Cannot write image to file %s: %s'%(source, get_exception(wand)))
_libwand.DestroyMagickWand(wand) _libwand.DestroyMagickWand(wand)
_libwand.MagickWandTerminus() _libwand.MagickWandTerminus()