Reading image dimensions with PIL
Fredrik Lundh
fredrik at pythonware.com
Wed May 18 08:44:48 EDT 2005
Will McGugan wrote:
> I'm writing an app that downloads images. It rejects images that are
> under a certain size - whithout downloading them completely. I've
> implemented this using PIL, by downloading the first K and trying to
> create a PIL image with it. PIL raises an exception because the file is
> incomplete, but the image object is initialised with the image
> dimensions, which is what I need. It actualy works well enough, but I'm
> concerened about side-effects - since it seems an unconventional way of
> working with PIL. Can anyone see any problems with doing this? Or a
> better method?
the "right" way to do this is to use the ImageFile.Parser class. see the
last snippet on this page for an example:
http://effbot.org/zone/pil-image-size.htm
</F>
More information about the Python-list
mailing list