Skip to main content

Find the size or type of the image without fetching the whole content.

Project description

imgspy finds the metadata (type, size) of an image given its url by fetching as little as needed. This is a python implementation of fastimage. Supports image types BMP, CUR, GIF, ICO, JPEG, PNG, PSD, TIFF, WEBP.

usage

>>> imgspy.info('http://via.placeholder.com/1920x1080')
{'type': 'png', 'width': 1920, 'height': 1080}
>>> with requests.get('http://via.placeholder.com/1920x1080', stream=True) as res:
...     imgspy.info(res.raw)
{'type': 'png', 'width': 1920, 'height': 1080}
>>> imgspy.info('/path/to/image.jpg')
{'type': 'jpg', 'width': 420, 'height': 240}
>>> with open('/path/to/image.jpg') as f:
...     imgspy.info(f)
{'type': 'jpg', 'width': 420, 'height': 240}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imgspy-0.2.1.tar.gz (2.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page