Beispiel #1
0
def identify_data(data):
    '''
    Identify the image in data. Returns a 3-tuple
    (width, height, format)
    or raises an Exception if data is not an image.
    '''
    img = Image()
    img.identify(data)
    width, height = img.size
    fmt = img.format
    return (width, height, fmt)
Beispiel #2
0
def identify_data(data):
    '''
    Identify the image in data. Returns a 3-tuple
    (width, height, format)
    or raises an Exception if data is not an image.
    '''
    img = Image()
    if hasattr(img, 'identify'):
        img.identify(data)
    else:
        img.load(data)
    width, height = img.size
    fmt = img.format
    return (width, height, fmt)
Beispiel #3
0
def identify_data(data):
    '''
    Identify the image in data. Returns a 3-tuple
    (width, height, format)
    or raises an Exception if data is not an image.
    '''
    if data.startswith(b'<?xml'):
        # ImageMagick segfaults when trying to identify SVG images
        raise ValueError('Identifying svg images is not supported')
    img = Image()
    img.identify(data)
    width, height = img.size
    fmt = img.format
    return (width, height, fmt)
Beispiel #4
0
def identify_data(data):
    """
    Identify the image in data. Returns a 3-tuple
    (width, height, format)
    or raises an Exception if data is not an image.
    """
    if data.startswith(b"<?xml"):
        # ImageMagick segfaults when trying to identify SVG images
        raise ValueError("Identifying svg images is not supported")
    img = Image()
    img.identify(data)
    width, height = img.size
    fmt = img.format
    return (width, height, fmt)
Beispiel #5
0
def identify_data(data):
    '''
    Identify the image in data. Returns a 3-tuple
    (width, height, format)
    or raises an Exception if data is not an image.
    '''
    if data.startswith(b'<?xml'):
        # ImageMagick segfaults when trying to identify SVG images
        raise ValueError('Identifying svg images is not supported')
    img = Image()
    if hasattr(img, 'identify'):
        img.identify(data)
    else:
        img.load(data)
    width, height = img.size
    fmt = img.format
    return (width, height, fmt)