I've been disecting the CPAN Image::Size module, and have found out some useful stuff 
that I wanted to share. The beginners list seemed an appropriate place.

Here's the algorithm for finding the height and width of a JPEG (all nambers are hex):

1. Skip the first two bytes of the file.
2. Read the next four bytes
    first byte->$marker
    second byte->$code
    byte 3 and 4->$length
3. If ($marker != FF) Bomb! It's not a JPEG!
4. If ($code>=C0) and ($code<=C3) GOTO 6
5. Skip the next ($length-2) bytes. GOTO 2.
6. Read the next 5 bytes. Discard the first byte.
    The height is in the second and third byte
    The width is in the fourth and fifth byte

Happy hacking!

--Nigel



Coming up tonight on ITV1 and ITV Digital:
*  Who Wants To Be A Millionaire? New series starts tonight - 8.00pm ITV1
*  Catch up with events in the Whitehouse in The West Wing - 9.00pm E4

***************************************
This E-mail message, including any attachments, is intended only for the person or 
entity to which it is addressed, and may contain confidential information.
If you are not the intended recipient, any review, retransmission, disclosure, 
copying, modification or other use of this E-mail message or attachments is strictly 
forbidden.
If you have received this E-mail message in error, please contact the author and 
delete the message and any attachments from your computer.
You are also advised that the views and opinions expressed in this E-mail message and 
any attachments are the author's own, and may not reflect the views and opinions of 
ITV Digital Plc, 346 Queenstown Rd, London SW8 4DG. Reg No. 3302715


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to