Determining an Image Size?

Greg Landrum gReGlAnDrUm at earthlink.net
Sat May 19 03:01:01 CEST 2001


"Darren Watson" <Darren.Watson3 at ntlworld.com> wrote in message
news:KjiN6.4874$Od1.660453 at news2-win.server.ntlworld.com...
> Hi
>
> I know very little about image formats, but I am very interested in
finding
> out if it is possible to determine the dimensions (in pixels) of a JPEG or
> GIF file from a Python script.
>

If you have PIL installed
(http://www.pythonware.com/products/pil/index.htm), you can just do:
>>> from PIL import Image
>>> img = Image.open('icon.jpg')
>>> img.size
(66, 81)

I hope this helps,
-greg






More information about the Python-list mailing list