[PYTHON IMAGE-SIG] width height of gif/jpeg files?
Mon, 10 Jun 1996 19:28:01 +0200
> What's the quickest way to read the width and height of image files?
> I want to write a little function to return this info for a bunch of
> image files. I don't have PIL (yet, I suppose that'll have the answer.)
Here's the minimal PIL version:
import sys, Image
for f in sys.argv[1:]:
print f, Image.open(f).size
When you open a file in PIL, it only parses the file header. The
raster data is not read until you try to do something with it, so the
above is quite fast, independent of the image size.
See the pilfile.py script for a somewhat more polished variant.
BTW, you don't have to link with the PIL C extension to use the above
IMAGE-SIG - SIG on Image Processing with Python
send messages to: firstname.lastname@example.org
administrivia to: email@example.com