diff --git a/ChangeLog.md b/ChangeLog.md index 46ca8cb1..8b1ebd8a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -51,6 +51,10 @@ cropping regions to be unduly rejected when performing 90-degree rotation, 270-degree rotation, transposition, transverse transposition, or grayscale conversion. +8. Fixed an issue whereby the TurboJPEG lossless transformation function and +methods did not honor `TJXOPT_COPYNONE`/`TJTransform.OPT_COPYNONE` unless it +was specified for all lossless transforms. + 3.0.3 ===== diff --git a/transupp.c b/transupp.c index 62587d38..0a92413a 100644 --- a/transupp.c +++ b/transupp.c @@ -2315,19 +2315,20 @@ jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option) #ifdef SAVE_MARKERS_SUPPORTED int m; - /* Save comments except under NONE option */ + /* Save comments unless JCOPYOPT_NONE or JCOPYOPT_ICC specified */ if (option != JCOPYOPT_NONE && option != JCOPYOPT_ICC) { jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF); } - /* Save all types of APPn markers iff ALL option */ + /* Save all APPn markers iff JCOPYOPT_ALL* specified ... */ if (option == JCOPYOPT_ALL || option == JCOPYOPT_ALL_EXCEPT_ICC) { for (m = 0; m < 16; m++) { + /* ... except APP2 markers if JCOPYOPT_ALL_EXCEPT_ICC specified */ if (option == JCOPYOPT_ALL_EXCEPT_ICC && m == 2) continue; jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF); } } - /* Save only APP2 markers if ICC option selected */ + /* Save only APP2 markers if JCOPYOPT_ICC specified */ if (option == JCOPYOPT_ICC) { jpeg_save_markers(srcinfo, JPEG_APP0 + 2, 0xFFFF); } @@ -2347,12 +2348,22 @@ jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, { jpeg_saved_marker_ptr marker; - /* In the current implementation, we don't actually need to examine the - * option flag here; we just copy everything that got saved. - * But to avoid confusion, we do not output JFIF and Adobe APP14 markers - * if the encoder library already wrote one. - */ for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) { + if (option == JCOPYOPT_NONE) + continue; + else if (option == JCOPYOPT_COMMENTS) { + if (marker->marker != JPEG_COM) + continue; + } else if (option == JCOPYOPT_ALL_EXCEPT_ICC) { + if (marker->marker == JPEG_APP0 + 2) + continue; + } else if (option == JCOPYOPT_ICC) { + if (marker->marker != JPEG_APP0 + 2) + continue; + } + /* To avoid confusion, we do not output JFIF and Adobe APP14 markers if the + * encoder library already wrote one. + */ if (dstinfo->write_JFIF_header && marker->marker == JPEG_APP0 && marker->data_length >= 5 &&