[Tutor] Reading image dimensions before it is loaded from a web form using python.

Norman Khine norman at khine.net
Fri Jun 29 19:12:46 CEST 2007


Hello,
I am writing an application that allows the user to upload an image to
their folder.
Is there a way to get the size of the file before it has been uploaded
onto the server and give an error if the size does not comply to the
maximum size.

So far, my apps loads the image and checks it and then returns the
error. Which is a bit pointless in that I should be able to get the file
info before it is loaded, but I am not sure where to go.

PIL reads the image size before it is loaded, but this is when I run
this on my local machine. There is also a post
http://mail.python.org/pipermail/python-list/2005-May/323018.html by
Will McGugan where he loads 1px and rejects it if its too big. But his
apps is an image scraper, so I suppose it fits his use case where he
checks the size and then pulls the image if it fits.

Anyone with ideas on how to deal with this.

Thanks

Norman


-- 
Norman Khine




More information about the Tutor mailing list