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)
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)
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)
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)
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)