At 14:52 +0000 15/2/06, Moisés Chicharro wrote:
My main aims being:
- check uploaded image filesize is not too large (most important)
Others have explained how to do this.
- check uploaded image physical pixel size
This can be done relatively easily by parsing the JFIF tags.
The JPEG/JFIF file format is just:
FF D8 - Start of Image marker
Followed by a sequence of headers:
FF xx - header tag xx
length (two bytes, big endian) - length of header including these two bytes
header data
The actual data for the image follows the Start
of Scan marker (FF DA) header, and the header you
want is the Start of frame marker (FF C0) header,
where the data for the header is:
P -- one byte: sample precision in bits (usually 8, for baseline JPEG)
Y -- two bytes
X -- two bytes
other stuff <see
http://www.obrador.com/essentialjpeg/headerinfo.htm>
for details.
Parsing this format sufficiently to read the X &
Y size should not be very challenging.
- change uploaded image physical pixel size (if possible without module)
As mentioned, you could just specify height and
width in your HTML/CSS to set a maximum display
size. Actually reprocessing the image to change
the size without a library would be quite
challenging.
Enjoy,
Peter.
--
<http://www.stairways.com/> <http://download.stairways.com/>