Reading image dimensions before it is loaded from a web form usingpython.

N

Norman Khine

Hello,
I am writing an application using python that allows the user to upload
an image to a folder on the server.

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 an error
if the image is too big. 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top