imagesize
Get image size from headers (BMP/PNG/JPEG/JPEG2000/GIF/TIFF/SVG/Netpbm/WebP/AVIF/HEIC/HEIF)
Decision gist · record as of 2026-08-14
Yes. This is a lightweight, actively maintained, zero-dependency library with no known vulnerabilities, permissive licensing, and a focused purpose. Install it if you need fast image header parsing without the overhead of a full image library; the trade-off is that it only works on headers, not pixel data.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later (supports 3.10–3.14); version 2.0 returns (-1, -1) on parse failures instead of raising exceptions.
- No runtime dependencies and a pure Python implementation with low install friction.
- Actively maintained as of 2026-03-03 with recent updates to version 2.0.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions in commercial or open-source projects.
last release 2026-03-03 (164 days) · last repo commit 2026-03-03 · 253 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 31,730,124 downloads/mo, #782 on PyPI
Alternatives
Verify before relying
pip install imagesize
import imagesize
width, height = imagesize.get("test.png")
print(width, height)
xdpi, ydpi = imagesize.getDPI("test.png")
print(xdpi, ydpi)
info = imagesize.get_info("test.png")
print(info.width, info.height, info.rotation, info.xdpi, info.ydpi)- Whether file-like objects (io.BytesIO) work with all supported formats or only a subset.
- Performance comparison with other pure-Python image header libraries beyond Pillow.
What it is and what it does
imagesize is a pure Python library that parses image file headers to extract dimensions, DPI, and metadata without reading pixel data. It supports a wide range of formats including JPEG, PNG, GIF, TIFF, SVG, WebP, BMP, AVIF, HEIC, and HEIF. The library provides three main functions: get() returns width and height, getDPI() returns horizontal and vertical DPI, and get_info() returns a named tuple with width, height, rotation, DPI, color depth, and channel count.
Version 2.0 added support for AVIF and HEIC/HEIF, improved EXIF orientation handling so rotated images return corrected dimensions, and added type hints. A key design choice is that it only parses headers, making it significantly faster than image libraries that load full pixel data. The library accepts file paths or file-like objects, and by default applies EXIF rotation metadata; you can disable this with exif_rotation=False.
Use it for
- Quickly determine image dimensions in web applications without loading full images into memory.
- Extract DPI and rotation metadata from JPEG and TIFF files for print workflows.
- Batch process image metadata from directories to catalog or validate image properties.
- Build image galleries or thumbnails that need dimensions before rendering.
- Validate image format and dimensions in upload handlers before storing files.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
This is a lightweight, actively maintained, zero-dependency library with no known vulnerabilities, permissive licensing, and a focused purpose. Install it if you need fast image header parsing without the overhead of a full image library; the trade-off is that it only works on headers, not pixel data.
Install
imagesize on PyPI
Before you install
No runtime dependencies and a pure Python implementation with low install friction. Actively maintained as of 2026-03-03 with recent updates to version 2.0.
Requires Python 3.10 or later (supports 3.10–3.14); version 2.0 returns (-1, -1) on parse failures instead of raising exceptions.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions in commercial or open-source projects.
Quickstart
pip install imagesize
import imagesize
width, height = imagesize.get("test.png")
print(width, height)
xdpi, ydpi = imagesize.getDPI("test.png")
print(xdpi, ydpi)
info = imagesize.get_info("test.png")
print(info.width, info.height, info.rotation, info.xdpi, info.ydpi)
Verify before relying
- Whether file-like objects (io.BytesIO) work with all supported formats or only a subset.
- Performance comparison with other pure-Python image header libraries beyond Pillow.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <3.15,>=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 164 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 31,730,124 / month, #782 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Multimedia :: Graphics |
Evidence: imagesize-2.0.0-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “get image dimensions from file”
- imagesizeReads image file headers to extract dimensions, DPI, and metadata…
- pymediainfopymediainfo extracts detailed metadata from multimedia files by…
- faviconFetches and parses a website's favicon from its HTML, returning icon…
Give your agent the search over MCP, or paste the wish link into any chat.
More Graphics packages
Pillow adds image processing capabilities to Python, providing file format support, efficient pixel data handling, and image manipulation operations.
Install it if you need to work with images in Python—it is the de facto standard for this task.
fonttools manipulates font files in multiple formats (TrueType, OpenType, AFM, Type 1, Mac-specific) and includes TTX, a tool to convert fonts to and from XML text format.
Install it if you need to read, write, or manipulate fonts programmatically or via the TTX command-line tool.
Enables matplotlib figures to display inline directly within Jupyter notebooks and IPython environments instead of in separate windows.
PyMuPDF extracts, renders, converts, and manipulates PDF and other document formats (XPS, EPUB, images, Office files via Pro) with high performance, providing text, tables, images, and metadata with precise layout information.
The AGPL license requires careful review if you are building proprietary software—commercial licensing is available from Artifex.
pypdfium2 is a Python binding to PDFium that enables PDF rendering, inspection, manipulation, and creation through a ctypes interface to Google's PDFium library.
Install it if you need PDF rendering, inspection, or manipulation in Python; the medium install friction is offset by comprehensive platform support.
Altair is a declarative Python library for creating interactive statistical visualizations by writing simple, readable code that compiles to Vega-Lite specifications.
See also ExifRead · pyheif · pi-heif · pillow-heif · exif · OpenImageIO · piexif · pillow-avif-plugin · PIMS · pyexiv2