Reading JPEG header information : Graphics
This is a discussion on Reading JPEG header information within the Graphics forums in Theory and Concepts category; I need to be able to interpret the header information in a JPEG image file. I've been poking through Google hits, but am pretty much lost ... should I be looking at the EXIF, JFIF or JIF specifications? Or maybe some other, more global specification document that includes the others? Can anyone here direct me to a comprehensive specification document with field and byte layouts for JPEG files? Right now, I just need to be able to read the dimensions of the image....
![]() |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| I've been poking through Google hits, but am pretty much lost ... should I be looking at the EXIF, JFIF or JIF specifications? Or maybe some other, more global specification document that includes the others? Can anyone here direct me to a comprehensive specification document with field and byte layouts for JPEG files? Right now, I just need to be able to read the dimensions of the image. |
|
#2
| |||
| |||
| Z wrote: > I need to be able to interpret the header information in a JPEG image file. > > I've been poking through Google hits, but am pretty much lost ... should > I be looking at the EXIF, JFIF or JIF specifications? Or maybe some > other, more global specification document that includes the others? > > Can anyone here direct me to a comprehensive specification document with > field and byte layouts for JPEG files? > > Right now, I just need to be able to read the dimensions of the image. This pdf document has details on the structure of the header: http://www.w3.org/Graphics/JPEG/jfif3.pdf This site contains essentially the same information with a little different spin: http://netghost.narod.ru/gff/graphics/summary/jfif.htm |
|
#3
| |||
| |||
| Z wrote: > I need to be able to interpret the header information in a JPEG image file. > > I've been poking through Google hits, but am pretty much lost ... should > I be looking at the EXIF, JFIF or JIF specifications? Or maybe some > other, more global specification document that includes the others? > > Can anyone here direct me to a comprehensive specification document with > field and byte layouts for JPEG files? > > Right now, I just need to be able to read the dimensions of the image. When I wanted to reset EXIF timestamps on a batch of images, Google took me straight to what I needed. Later on I discovered that the functionality I needed had already been implemented as open source several times. For the header stuff (not the image itself) check out libexif. It might save you a lot of time. Paul Allen |
|
#4
| |||
| |||
| Paul Allen wrote: >> Right now, I just need to be able to read the dimensions of the image. > When I wanted to reset EXIF timestamps on a batch of images, Google took > me straight to what I needed. Later on I discovered that the > functionality I needed had already been implemented as open source > several times. For the header stuff (not the image itself) check out > libexif. It might save you a lot of time. I found libexif and played a bit, but my target o/s is VMS and because of the makefiles it's going to take a huge effort to build that code on any o/s other than Unix/Linux. I only need a very specific set of data: just the height and width in pixels (and I'm not sure it's in the EXIF section), so I think my path of least resistance is to decode the correct header myself. |
|
#5
| |||
| |||
| Jim Townsend wrote: > Z wrote: > > >>I need to be able to interpret the header information in a JPEG image file. >> >>I've been poking through Google hits, but am pretty much lost ... should >>I be looking at the EXIF, JFIF or JIF specifications? Or maybe some >>other, more global specification document that includes the others? >> >>Can anyone here direct me to a comprehensive specification document with >>field and byte layouts for JPEG files? >> >>Right now, I just need to be able to read the dimensions of the image. > > > This pdf document has details on the structure of the header: > http://www.w3.org/Graphics/JPEG/jfif3.pdf Thanks. In that document I see Xdensity and Ydensity but that can't be height and width ... I have 2 JPGs, one 200x200 and another 400x400 (a resized version of the 200x200 image) and both have the same Xdensity and Ydensity fields within the JFIF header. 200x200: FF D8 FF E0 10 4A 46 49 46 00 01 01 00 00 01 00 01 00 00 FF E1 1C 86 45 78 69 66 00 ( ver 1.1, units = 0, Xdensity = 00 01, Ydensity = 00 01 ) 400x400: FF D8 FF E0 10 4A 46 49 46 00 01 01 00 00 01 00 01 00 00 ff E1 1C 86 45 78 69 66 00 ( ver 1.1, units = 0, Xdensity = 00 01, Ydensity = 00 01 ) How do I convert the densities (actually the pixel aspect ratio, since the units byte is 00) to number-of-pixels? |
|
#6
| |||
| |||
| Z <Z@no.spam> wrote: >Paul Allen wrote: >>> Right now, I just need to be able to read the dimensions of the image. > >> When I wanted to reset EXIF timestamps on a batch of images, Google took >> me straight to what I needed. Later on I discovered that the >> functionality I needed had already been implemented as open source >> several times. For the header stuff (not the image itself) check out >> libexif. It might save you a lot of time. > >I found libexif and played a bit, but my target o/s is VMS and because >of the makefiles it's going to take a huge effort to build that code on >any o/s other than Unix/Linux. > >I only need a very specific set of data: just the height and width in >pixels (and I'm not sure it's in the EXIF section), so I think my path >of least resistance is to decode the correct header myself. Grabbing any given bits of information from the EXIF headers is fairly easy to do (like everything else, once you figure out how), and can be done with Standard C that will compile on virtually any platform. A while back I was fooling around with a short program to read EXIF headers from Nikon NEF formatted files, and more or less on a whim also added the ability to read JPEG files. I was only really interested in NEF files though, and while I researched that to the bottom of the stack, I only looked into JPEG EXIF headers enough to pull out a few things. I don't recall having found any really good information on JPEG headers, and mostly just reverse engineered the format from examples generated by the particular (Nikon D1) camera that I was interested in at the time. I've also tested it on JPEGs produced by a Canon 5D, where the only information that appears to be correct is the camera, the date, and the image size. :-) The program is strictly ANSI, and uses stdio.h, stdlib.h, and strings.h only. No system/platform specific headers at all. And nothing other than libc is linked. My code obviously has 100 times more clutter than you need, but if it would be any help, point me at a URL that has an example JPEG file you want information from, and I'll post the shortest most basic example code I can come up with to extract the size in pixels from it. It might save you a little thrashing... -- Floyd L. Davidson http://www.apaflo.com/floyd_davidson Ukpeagvik (Barrow, Alaska) floyd@apaflo.com |
|
#7
| |||
| |||
| Z wrote: > Paul Allen wrote: > >>> Right now, I just need to be able to read the dimensions of the image. >> When I wanted to reset EXIF timestamps on a batch of images, Google took >> me straight to what I needed. Later on I discovered that the >> functionality I needed had already been implemented as open source >> several times. For the header stuff (not the image itself) check out >> libexif. It might save you a lot of time. > I found libexif and played a bit, but my target o/s is VMS and because > of the makefiles it's going to take a huge effort to build that code on > any o/s other than Unix/Linux. > > I only need a very specific set of data: just the height and width in > pixels (and I'm not sure it's in the EXIF section), so I think my path > of least resistance is to decode the correct header myself. I did that myself before I stumbled over libexif and the various things on top of it. I've got some code that parses the internal structures of a JPEG file. I built it to increment the datestamps on a whole bunch of images, but that logic is up in the main program. The underlying exif.c logic knows all about things like the tags containing the image dimensions. It does have a Makefile, but that's not really needed. It definitely does not use autoconf and does not have a configure script. If you're interested, I can put it up on my web site. It's been a really long time (20 years, in fact) since I touched VMS. Can you handle a gzipped tarfile? A plain tar archive? Plain newline-delimited ASCII text files? I once warped the GNU C compiler on an Ultrix VAX into a cross-compiler for Minix running on a 386, so I guess VAXen have the same byte-sex as PC's. Paul Allen |
|
#8
| |||
| |||
| Thank you all for the help ... I've found what I need here: http://dev.w3.org/cvsweb/Amaya/libjpeg/ (rdjpgcom.c) Small, compact and easy to build on VMS. |
|
#9
| |||
| |||
| On Fri, 11 Nov 2005 21:46:45 -0800, Z <Z@no.spam> wrote: >Paul Allen wrote: >>> Right now, I just need to be able to read the dimensions of the image. > >> When I wanted to reset EXIF timestamps on a batch of images, Google took >> me straight to what I needed. Later on I discovered that the >> functionality I needed had already been implemented as open source >> several times. For the header stuff (not the image itself) check out >> libexif. It might save you a lot of time. > >I found libexif and played a bit, but my target o/s is VMS and because >of the makefiles it's going to take a huge effort to build that code on >any o/s other than Unix/Linux. VMS as in DEC? An 11/780 in your home office? Actually, I remember someone telling me that (around 1985) about one quarter of the VAXen in use were running some version of UNIX instead of VMS. |
|
#10
| |||
| |||
| Z <Z@no.spam> writes: > Paul Allen wrote: >>> Right now, I just need to be able to read the dimensions of the image. > >> When I wanted to reset EXIF timestamps on a batch of images, Google took >> me straight to what I needed. Later on I discovered that the >> functionality I needed had already been implemented as open source >> several times. For the header stuff (not the image itself) check out >> libexif. It might save you a lot of time. > > I found libexif and played a bit, but my target o/s is VMS and because > of the makefiles it's going to take a huge effort to build that code > on any o/s other than Unix/Linux. Try the Perl package Image::ExifTool. It's pure Perl, and Perl runs everywhere. > I only need a very specific set of data: just the height and width in > pixels (and I'm not sure it's in the EXIF section), so I think my path > of least resistance is to decode the correct header myself. Decoding the width and height from the JPEG header is rather easy. ITU T81 is the document you want for reference. -- Måns Rullgård mru@inprovide.com |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Jpeg camera information missing. | usenet | Adobe Photoshop | 1 | 09-01-2007 02:36 PM |
| Reading JPEG data | usenet | Idl-pvwave | 0 | 03-28-2007 02:30 PM |
| Maximum size of a jpeg header | usenet | Graphics | 1 | 05-31-2006 06:34 AM |
| JPEG File with strange markers and no header | usenet | Graphics | 0 | 01-10-2006 11:36 AM |
| Jpeg header decoding (dpi) | usenet | Java-Games | 4 | 08-27-2004 02:55 AM |
All times are GMT -5. The time now is 12:48 AM.



