[Pythonmac-SIG] Geting information about images
Dinu Gherman
gherman@darwin.in-berlin.de
Wed, 11 Sep 2002 19:02:15 +0200
Josh English:
> I have a quick question which will probably lead to a long answer. I
> would like to find a way for python to examine a .jpeg or .gif file and
> return the image dimensions in pixels.
>
> I've been looking through the img* files but I can't find anything so
> simple.
>
> Thanks for any help,
Let me try giving a short answer. What you need is PIL from
pythonware.com. Then you can write a snippet like the one
below.
Dinu
>>> import Image
>>> im = Image.open("lena.jpg")
>>> print im.format, im.size, im.mode
JPEG (208, 222) RGB
>>> im.save("lena.png", "PNG")