Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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