Reading image dimensions with PIL

Will McGugan news at NOwillmcguganSPAM.com
Tue May 17 11:35:55 EDT 2005


Hi,

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?


Thanks,

Will McGugan


-- 
http://www.willmcgugan.com
"".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c 
in "jvyy*jvyyzpthtna^pbz" ] )



More information about the Python-list mailing list