Commit 0775540b5 for imagemagick.org
commit 0775540b5842559319cf9edfa990fddf8c03bbc8
Author: Greg B <64932474+gregbenz@users.noreply.github.com>
Date: Fri Sep 11 06:08:56 2026 -0500
Preserve IPTC profiles during automatic Ultra HDR decoding (#8952)
diff --git a/Makefile.in b/Makefile.in
index 04fb2f3ad..665fb6f44 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -6296,6 +6296,7 @@ TESTS_TESTS = \
TESTS_EXTRA_DIST = \
tests/common.shi \
tests/rose.pnm \
+ tests/cli-uhdr-iptc.jpg \
tests/input_svg_gradient_transform.svg \
tests/input_svg_inline_style.svg \
tests/input_256c.miff \
diff --git a/coders/jpeg.c b/coders/jpeg.c
index c6d9cba81..e6a6ccfef 100644
--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -1622,6 +1622,9 @@ static Image *ReadOneJPEGImage(const ImageInfo *image_info,
*comment,
*sampling_factor;
+ const StringInfo
+ *profile;
+
ExceptionInfo
*uhdr_exception;
@@ -1653,6 +1656,9 @@ static Image *ReadOneJPEGImage(const ImageInfo *image_info,
uhdr_image->quality=image->quality;
uhdr_image->resolution=image->resolution;
uhdr_image->units=image->units;
+ profile=GetImageProfile(image,"iptc");
+ if (profile != (const StringInfo *) NULL)
+ (void) SetImageProfile(uhdr_image,"iptc",profile,uhdr_exception);
sampling_factor=GetImageProperty(image,"jpeg:sampling-factor",
exception);
if (sampling_factor != (const char *) NULL)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c1c61e32d..062cec84b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -65,6 +65,7 @@ TESTS_TESTS = \
TESTS_EXTRA_DIST = \
tests/common.shi \
tests/rose.pnm \
+ tests/cli-uhdr-iptc.jpg \
tests/input_svg_gradient_transform.svg \
tests/input_svg_inline_style.svg \
tests/input_256c.miff \
diff --git a/tests/cli-uhdr-iptc.jpg b/tests/cli-uhdr-iptc.jpg
new file mode 100644
index 000000000..6036ce844
Binary files /dev/null and b/tests/cli-uhdr-iptc.jpg differ
diff --git a/tests/cli-uhdr.tap b/tests/cli-uhdr.tap
index de5e67abb..83c8edb2b 100755
--- a/tests/cli-uhdr.tap
+++ b/tests/cli-uhdr.tap
@@ -50,6 +50,9 @@ reduced_phase_sequential=cli-uhdr-crop-replay-reduced-phase-sequential.jpg
reduced_phase_direct=cli-uhdr-crop-replay-reduced-phase-direct.jpg
reduced_phase_sequential_linear=cli-uhdr-crop-replay-reduced-phase-sequential-linear.miff
reduced_phase_direct_linear=cli-uhdr-crop-replay-reduced-phase-direct-linear.miff
+iptc_fixture=${SRCDIR}/cli-uhdr-iptc.jpg
+iptc_source=cli-uhdr-iptc-source.iptc
+iptc_output=cli-uhdr-iptc-output.iptc
capacity_min=1.00000012
capacity_max=2.00000024
expected_offsets='1.00000001e-07,1.00000001e-07,1.00000001e-07 1.00000001e-07,1.00000001e-07,1.00000001e-07'
@@ -59,7 +62,8 @@ comments-local-second-line'
cleanup()
{
rm -f "$raw_source" "$source" "$output" "$transformed_output" \
- "$locale_output" "$jpeg_probe" "$whitespace_output" "$invalid_output"
+ "$locale_output" "$jpeg_probe" "$whitespace_output" "$invalid_output" \
+ "$iptc_source" "$iptc_output"
rm -f "$commented_source" "$comment_roundtrip" \
"$comment_linear" "$crop_sequential" "$crop_direct" \
"$crop_sequential_linear" "$crop_direct_linear" "$reduced_seed" \
@@ -109,7 +113,7 @@ if [ "X$jpeg_format" != "XJPEG" ]; then
exit 0
fi
-echo "1..18"
+echo "1..20"
if ! ${MAGICK} \( "${SRCDIR}/rose.pnm" -depth 8 \) \
\( "${SRCDIR}/rose.pnm" -depth 16 \) \
-define uhdr:hdr-color-transfer=linear "UHDR:$raw_source" \
@@ -145,6 +149,17 @@ if ! ${MAGICK} \( "${SRCDIR}/rose.pnm" -depth 8 -resize 50% \) \
exit 0
fi
+if ${MAGICK} -define jpeg:detect-uhdr=false "$iptc_fixture" \
+ "IPTC:$iptc_source" >/dev/null 2>&1 && [ -s "$iptc_source" ] && \
+ ${MAGICK} "$iptc_fixture" "IPTC:$iptc_output" >/dev/null 2>&1 && \
+ cmp -s "$iptc_source" "$iptc_output"; then
+ echo "ok - IPTC profile survives automatic UHDR read"
+else
+ echo "not ok - IPTC profile survives automatic UHDR read"
+fi
+hdrgm=`${IDENTIFY} -quiet -format '%[jpeg:hdrgm]' "$iptc_fixture" 2>/dev/null`
+check_value "IPTC fixture uses automatic UHDR routing" "$hdrgm" true
+
if ${MAGICK} "UHDR:$source" \
-set hdrgm:OffsetSDR ' 0.0000001 , 0.0000001 , 0.0000001 ' \
-set hdrgm:OffsetHDR ' 0.0000001 , 0.0000001 , 0.0000001 ' \