Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

JPEG image compression FAQ, part 1/2
Section - [22] How can my program extract image dimensions from a JPEG file?

( Part1 - Part2 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Zip codes ]


Top Document: JPEG image compression FAQ, part 1/2
Previous Document: [21] What if I need more than 8-bit precision?
Next Document: [23] Where can I learn about using images on the World Wide Web?
See reader questions & answers on this topic! - Help others by sharing your knowledge
The header of a JPEG file consists of a series of blocks, called "markers".
The image height and width are stored in a marker of type SOFn (Start Of
Frame, type N).  To find the SOFn you must skip over the preceding markers;
you don't have to know what's in the other types of markers, just use their
length words to skip over them.  The minimum logic needed is perhaps a page
of C code.  (Some people have recommended just searching for the byte pair
representing SOFn, without paying attention to the marker block structure.
This is unsafe because a prior marker might contain the SOFn pattern, either
by chance or because it contains a JPEG-compressed thumbnail image.  If you
don't follow the marker structure you will retrieve the thumbnail's size
instead of the main image size.)  A profusely commented example in C can be
found in rdjpgcom.c in the IJG distribution (see part 2, item 15).  Perl
code can be found in wwwis, from http://www.tardis.ed.ac.uk/~ark/wwwis/.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: JPEG image compression FAQ, part 1/2
Previous Document: [21] What if I need more than 8-bit precision?
Next Document: [23] Where can I learn about using images on the World Wide Web?

Part1 - Part2 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
jpeg-info@uunet.uu.net





Last Update March 27 2014 @ 02:11 PM