Exif Patch (Jan 07 2001)
There have recently been encountered problems with Exif metadata
preservation after manipulation of digital camera image files.
Exif data is not recognized by certain Exif readers
after lossless rotation with IJG based software, although the "Copy
All" switch has been set.
Programs or devices refuse to open the image, although the
Exif data is recognized.
Explanation of the problems:
Solution of the problems:
IJG based software writes a JFIF APP0 marker between SOI and Exif APP1
According to the Exif specification,
the Exif APP1 marker has to follow immediately
after the SOI, just as the JFIF specification requires the same for the
JFIF APP0 marker!
Therefore a JPEG file cannot legally be both Exif and JFIF at the same time!
Exif data contains two Tags ExifImageWidth
They have to match the corresponding values in the JPEG SOF marker!
They must therefore be updated after image manipulations which change
the width or height of the image (rotate, crop, re-size)!
Inserted in the code is a new local function adjust_exif_parameters()
(located above jtransform_adjust_parameters()).
The function is called from a new code fragment in function jtransform_adjust_parameters() below, titeled "Adjust Exif properties".
After checking for a valid Exif marker, the JFIF marker output is
suppressed by setting the dstinfo->write_JFIF_header field
As in function jcopy_markers_execute(), examining the copy option flag
can be avoided by just checking the srcinfo->marker_list field,
which is set accordingly due to jcopy_markers_setup(). Also note that
the APP1 marker must be the first marker according to the Exif spec, so
we don't need to traverse the whole marker_list.
- Download the new library in one of the following forms:
- official IJG JPEG 9 release version at
- part of the Jpegcrop Windows source archive (~5 MB):
- part of the initial Jpegcrop port to Unix archive (~3 MB):
- Or just see and adapt the new part in
transupp.c for other application.
Update (Feb 17 2002)
Exif Orientation Tag
Answer & solution: Exif
- Your patch is incomplete. The Exif spec describes an Orientation Tag.
Shouldn't this be updated, too, by the jpegtran patch?
- My digital camera alters the Exif Orientation Tag to indicate the
orientation of the captured scene. Isn't it possible to automatically
correct the indicated images with jpegtran so that they come out in
Page last modified: 13-Jan-2013
Back to the JPEGclub.org Jpegcrop & jpegtran page