def save( self, file = None ): ''' Saves the image to a file. If no file is specified, the file is saved with the original filename.''' if hasattr( file, 'write' ): size = size_t() b = api.MagickGetImageBlob( self._wand, size ) try: file.write( ''.join( [chr( b[i] ) for i in range( 0, size.value + 1 )] ) ) finally: api.MagickRelinquishMemory( b ) else: self._check_wand_error( api.MagickWriteImage( self._wand, file ) )
def save(self, file=None): ''' Saves the image to a file. If no file is specified, the file is saved with the original filename.''' if hasattr(file, 'write'): size = size_t() b = api.MagickGetImageBlob(self._wand, size) try: file.write(''.join( [chr(b[i]) for i in range(0, size.value + 1)])) finally: api.MagickRelinquishMemory(b) else: self._check_wand_error(api.MagickWriteImage(self._wand, file))
def dump( self, type = None ): ''' Save the image to a buffer, if no type is specified, original type is used. returns image''' if type: api.MagickSetFilename( self._wand, 'buffer.%s' % type ) # hint image type result = '' size = size_t() b = api.MagickGetImageBlob( self._wand, size ) try: result = ''.join( [chr( b[i] ) for i in range( 0, size.value + 1 )] ) finally: api.MagickRelinquishMemory( b ) return result
def dump(self, type=None): ''' Save the image to a buffer, if no type is specified, original type is used. returns image''' if type: api.MagickSetFilename(self._wand, 'buffer.%s' % type) # hint image type result = '' size = size_t() b = api.MagickGetImageBlob(self._wand, size) try: result = ''.join([chr(b[i]) for i in range(0, size.value + 1)]) finally: api.MagickRelinquishMemory(b) return result