Exif Patch (Jan 07 2001)

There have recently been encountered problems with Exif metadata preservation after manipulation of digital camera image files.

First problem:
Exif data is not recognized by certain Exif readers after lossless rotation with IJG based software, although the "Copy All" switch has been set.
Second problem:
Programs or devices refuse to open the image, although the Exif data is recognized.
Explanation of the problems:

  1. IJG based software writes a JFIF APP0 marker between SOI and Exif APP1 marker.
    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!

  2. Exif data contains two Tags ExifImageWidth and ExifImageHeight.
    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)!
Solution of the problems: 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 to FALSE. 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.

Update (Feb 17 2002)

Exif Orientation Tag

Questions:
  1. Your patch is incomplete. The Exif spec describes an Orientation Tag. Shouldn't this be updated, too, by the jpegtran patch?

  2. 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 standard orientation?
Answer & solution: Exif Orientation Tag


Page last modified: 13-Jan-2013
J P E G
c l u b
. o r g
Back to the JPEGclub.org Jpegcrop & jpegtran page