[Tutor] Reading image dimensions before it is loaded from a web form using python.
Luke Paireepinart
rabidpoobear at gmail.com
Fri Jun 29 20:22:09 CEST 2007
Norman Khine wrote:
> 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.
>
[snip]
> Anyone with ideas on how to deal with this.
>
You'll have to use javascript.
Unless you want to tell the people "download and run x.py on your image
to determine if it will be rejected!"
if you want an auto check before they upload, you'll have to do
client-side scripting.
Python's not available for this. It only does server-side.
This is fine, but if you're processing the image dimensions server-side,
that means they already sent it to you.
So look for a javascript image processing library.
Alternatively, if by 'size' you meant 'filesize' you could do this much
more simply (using Javascript)
than having to process the actual image data to find the resolution.
HTH,
-Luke
More information about the Tutor
mailing list