示例#1
0
文件: io.py 项目: ppawlak/pystacia
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
示例#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
示例#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
示例#4
0
文件: io.py 项目: ppawlak/pystacia
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
示例#5
0
文件: io.py 项目: ppawlak/pystacia
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
示例#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
示例#7
0
文件: io.py 项目: ppawlak/pystacia
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
示例#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
示例#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
示例#10
0
文件: io.py 项目: ppawlak/pystacia
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