def read(spec, width=None, height=None, factory=None): image = _instantiate(factory) if width and height: c_call('magick', 'set_size', image, width, height) c_call(image, 'read', spec) return image
def ping(filename): image = _instantiate(None) c_call(image, 'ping', filename) result = { 'width': image.width, 'height': image.height, 'format': image.format } image.close() return result
def read_raw(raw, format, width, height, # @ReservedAssignment depth, factory=None): image = _instantiate(factory) c_call('magick', 'set_size', image, width, height) c_call('magick', 'set_depth', image, depth) format = format.upper() # @ReservedAssignment c_call('magick', 'set_format', image, format) if hasattr(raw, 'read'): raw = raw.read() c_call(image, ('read', 'blob'), raw, len(raw)) return image
def ping_blob(blob): image = _instantiate(None) if hasattr(blob, 'read'): blob = blob.read() c_call(image, ('ping', 'blob'), blob, len(blob)) result = { 'width': image.width, 'height': image.height, 'format': image.format } image.close() return result
def read_raw( raw, format, width, height, # @ReservedAssignment depth, factory=None): image = _instantiate(factory) c_call('magick', 'set_size', image, width, height) c_call('magick', 'set_depth', image, depth) format = format.upper() # @ReservedAssignment c_call('magick', 'set_format', image, format) if hasattr(raw, 'read'): raw = raw.read() c_call(image, ('read', 'blob'), raw, len(raw)) return image
def read_blob(blob, format, factory): # @ReservedAssignment image = _instantiate(factory) #resource = image.resource #if format: # ensure we always get bytes # format = b(format.upper()) # @ReservedAssignment # old_format = cdll.MagickGetImageFormat(resource) # template = formattable('Format "{0}" unsupported') # guard(resource, # lambda: cdll.MagickSetFormat(resource, format), # template.format(format)) if hasattr(blob, 'read'): blob = blob.read() c_call(image, ('read', 'blob'), blob, len(blob)) #if format: # guard(resource, # lambda: cdll.MagickSetFormat(resource, old_format)) return image