Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
read the width, height, and rotation of images.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
dimensions
sample
tests
.gitignore
CHANGES.txt
LICENSE.txt
README.md
README.txt
fabfile.py
requirements.txt
setup.py

README.md

dimensions

A pure Python library for reading the width and height of images.

installation

pip install dimensions

Done.

usage

For a single image:

> dimensions sample/sample.png
sample/sample.png
  width: 405
  height: 239
  content-type: image/png

Wildcards also work (escape * in markdown for PyPi RST...):

> dimensions sample/\*.png
sample/sample.png
  width: 405
  height: 239
  content-type: image/png
sample/sample2.png
  width: 473
  height: 469
  content-type: image/png

As always, full details are available via dimensions -h.

In Python code, simply call dimensions.dimensions. If you provide a sequence of filenames, you get back a sequence of tuples; if you provide just a single filename, you get back a single tuple.

import dimensions
dims = dimensions.dimensions('./sample/sample.png')
# (405, 239, 'image/png', './sample/sample.png')
Something went wrong with that request. Please try again.