Skip to content

Commit

Permalink
Always tweak EXIF w/h tags w/ lossless transforms
Browse files Browse the repository at this point in the history
... even if using libjpeg v6b emulation.  Previously
adjust_exif_parameters() was only called with libjpeg v7/v8 emulation,
but due to a bug (which this commit also fixes), it only worked properly
with libjpeg v8 emulation.
  • Loading branch information
dcommander committed Jan 20, 2017
1 parent 2252795 commit a0b7de9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ built with libjpeg v7 API/ABI emulation. This was apparently a long-standing
bug that has existed since the introduction of libjpeg v7/v8 API/ABI emulation
in libjpeg-turbo v1.1.

7. The lossless transform features in jpegtran and the TurboJPEG API will now
always attempt to adjust the EXIF image width and height tags if the image size
changed as a result of the transform. This behavior has always existed when
using libjpeg v8 API/ABI emulation. It was supposed to be available with
libjpeg v7 API/ABI emulation as well but did not work properly due to a bug.
Furthermore, there was never any good reason not to enable it with libjpeg v6b
API/ABI emulation, since the behavior is entirely internal. Note that
`-copy all` must be passed to jpegtran in order to transfer the EXIF tags from
the source image to the destination image.


1.5.1
=====
Expand Down
11 changes: 8 additions & 3 deletions transupp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,6 @@ transpose_critical_parameters (j_compress_ptr dstinfo)
* We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible.
*/

#if JPEG_LIB_VERSION >= 70
LOCAL(void)
adjust_exif_parameters (JOCTET *data, unsigned int length,
JDIMENSION new_width, JDIMENSION new_height)
Expand Down Expand Up @@ -1327,7 +1326,6 @@ adjust_exif_parameters (JOCTET *data, unsigned int length,
offset += 12;
} while (--number_of_tags);
}
#endif


/* Adjust output image parameters as needed.
Expand Down Expand Up @@ -1421,14 +1419,21 @@ jtransform_adjust_parameters (j_decompress_ptr srcinfo,
GETJOCTET(srcinfo->marker_list->data[5]) == 0) {
/* Suppress output of JFIF marker */
dstinfo->write_JFIF_header = FALSE;
#if JPEG_LIB_VERSION >= 70
/* Adjust Exif image parameters */
#if JPEG_LIB_VERSION >= 80
if (dstinfo->jpeg_width != srcinfo->image_width ||
dstinfo->jpeg_height != srcinfo->image_height)
/* Align data segment to start of TIFF structure for parsing */
adjust_exif_parameters(srcinfo->marker_list->data + 6,
srcinfo->marker_list->data_length - 6,
dstinfo->jpeg_width, dstinfo->jpeg_height);
#else
if (dstinfo->image_width != srcinfo->image_width ||
dstinfo->image_height != srcinfo->image_height)
/* Align data segment to start of TIFF structure for parsing */
adjust_exif_parameters(srcinfo->marker_list->data + 6,
srcinfo->marker_list->data_length - 6,
dstinfo->image_width, dstinfo->image_height);
#endif
}

Expand Down

0 comments on commit a0b7de9

Please sign in to comment.