GetImageSize

Andrew Dalke dalke at dalkescientific.com
Sun Nov 18 14:33:12 EST 2001


Ben Ocean:
>In PHP there is a library function called getimagesize(). What is the
>equivalent in python?

There are many possible answers.  You probably want to install
PIL (see http://www.secretlabs.com/products/pil/index.htm ).
With it, you open the image (with Image.open) and get the
'size' attribute, which the tuple of (width, height).

You could call external programs like ImageMagick or the
pbmutils to get the image size.

On IRIX, for .rgb files you can use imgfile.getsizes and
for jpeg the jpeg module.  Assuming they were built.

In wxPython use wxImage's GetWidth and GetHeight.

But in the core library there isn't any built-in function
for this.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list