ExifTool Forum

General => Metadata => Topic started by: Herman C on March 21, 2014, 03:34:17 PM

Title: Ascertain the offset to thumbnail in EXIF
Post by: Herman C on March 21, 2014, 03:34:17 PM
I believe ExifTool forum should be my last resort to resolve a problem I have in hand.  On an amateur/hobbyist basis I have been developing some graphic tools after my retirement.  In an on-going enhancement to my Paint program more recently, I have added a JPEG Mark Listing letting users to (i) carry out some operations on "marker" basis such as Add/Insert/Remove; and (ii) to inspect some information pertaining to a selected marker,  by a double-click on a selected marker, e.g. APP0 to see JFIF or JFXX header entries (and thumbnail if JFXX), SOF0 or SOF2 to see the respective header pieces,  and APP1 to view a listing of EXIF tags, with InterOp and GPS tags, if any, appended at the end in the listing. 

If there is a thumbnail in EXIF, the thumbnail image is also shown next to the above-said listing, with "Size", "Format", "Offset" and "Length" data.  Although I am able to get these, I am far from satisfied, because the thumbnail and the data are obtained through some kind of trick, not by an "official" means.  I obtain the thumbnail by testing "FFD8....FFD9" within EXIF bytes, then derive the said data in the course (I don't use any external DLL or EXE, not even GDIplus).

Earlier on I mentioned InterOp and GSP tags; they are obtained with the guidance of the respective offset values given in EXIF itself.  However, when it comes to thumbnail, I have failed to follow a similar path to obtain an "offset" for the thumbnail bytes.

Almost all of the web pages I visited had told me that there would be "JPEGOffset  513" and "JPEGLength  514" to refer to.  However, I have not been able to trap such tags in any of the many and assorted JPEG files that I have.  This forces me to just use the earlier-said trick to obtain the thumbnail and derive the offset and length data.

I wonder, is there a proper way of obtaining the "offset" of thumbnail bytes in EXIF?  If yes, how should I go about it?.  I should be grateful if someone is kind enough to enlighten me on this issue, thus satisfying my curiosity.

Title: Re: Ascertain the offset to thumbnail in EXIF
Post by: Phil Harvey on March 21, 2014, 07:10:40 PM
The EXIF information is in TIFF format.  The thumbnail image is stored in IFD1 of the TIFF information.  Reading the EXIF and TIFF specifications may help, but I find it REALLY helps to see how the data is arranged in the JPEG file.  For this, the ExifTool -htmlDump is priceless to me.  If you haven't discovered this feature, I suggest you investigate it.  If you have read the EXIF/TIFF specs, you should have an "ah-ha" moment after studying the -htmldump output.

- Phil
Title: Re: Ascertain the offset to thumbnail in EXIF
Post by: Herman C on March 21, 2014, 10:35:32 PM
Hi Phil,

I thank you very much for your help. "ExifTool -htmlDump" is indeed a marvel.

Your "The thumbnail image is stored in IFD1....." immediately opened up my mind.  Then, by examining the output of "-htmlDump", to and fro a couple of times at a few byte positions, the "ah-ha" moment did come pretty soon.

Meanwhile, the "IFD data structure" section on the web page http://www.media.mit.edu/pia/Research/deepview/exif.html had spared me digging into the detailed TIFF/JPEG specifications.

My problem has now been resolved and I am grateful for your help.

Herman