RANSOM DEMAND: Image Held Hostage!

Fredrik Lundh fredrik at pythonware.com
Sun Nov 18 15:32:13 EST 2001


Ben Ocean wrote:
> I need a way to size up images via script. Now, in that inferior scripting
> language known as PHP, *they* have such a tool: getimagesize(). Can it be
> that God's gift to scripting languages, Python, can't compete here?

if you spent as much time reading replies to your posts
as you spend on your subject lines, you would have solved
your problem days ago.

but alright, here's another version of the same reply:

def getimagesize(filename):
    # get size from one of 30+ image formats
    import Image
    return Image.open(filename).size

width, height = getimagesize(filename)

where the Image module is part of the Python Imaging Library:

http://www.pythonware.com/products/pil/index.htm

(you don't need to build the binary extension if all you
need is the size.  but it won't hurt)

</F>

<!-- (the eff-bot guide to) the python standard library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list