libtiff: Add some basic sanity checks for tiffcp and tiffcrop RGB->YCbCr JPEG conversions.

From 5d8db4b5af9bbab9346bf6f02a482b0cb4e73ac2 Mon Sep 17 00:00:00 2001
From: Lee Howard <[EMAIL REDACTED]>
Date: Wed, 22 May 2024 01:42:18 +0000
Subject: [PATCH] Add some basic sanity checks for tiffcp and tiffcrop
 RGB->YCbCr JPEG conversions.

---
 test/Makefile.am                  |   8 ++++++--
 test/images/32bpp-None.tiff       | Bin 0 -> 13222 bytes
 test/tiff2rgba-32bpp-None-jpeg.sh |   7 +++++++
 test/tiffcp-32bpp-None-jpeg.sh    |   7 +++++++
 test/tiffcrop-32bpp-None-jpeg.sh  |   7 +++++++
 5 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 test/images/32bpp-None.tiff
 create mode 100755 test/tiff2rgba-32bpp-None-jpeg.sh
 create mode 100755 test/tiffcp-32bpp-None-jpeg.sh
 create mode 100755 test/tiffcrop-32bpp-None-jpeg.sh

diff --git a/test/Makefile.am b/test/Makefile.am
index 2829a032..63d72de8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -61,7 +61,10 @@ JPEG_DEPENDENT_TESTSCRIPTS=\
 	tiff2rgba-quad-tile.jpg.sh \
 	tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh \
 	tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh \
-	tiff2rgba-ojpeg_single_strip_no_rowsperstrip.sh
+	tiff2rgba-ojpeg_single_strip_no_rowsperstrip.sh \
+	tiff2rgba-32bpp-None-jpeg.sh \
+	tiffcp-32bpp-None-jpeg.sh \
+	tiffcrop-32bpp-None-jpeg.sh
 endif
 else
 JPEG_DEPENDENT_CHECK_PROG=
@@ -211,7 +214,8 @@ TIFFIMAGES = \
 	images/testfax4.tiff \
 	images/deflate-last-strip-extra-data.tiff \
 	images/custom_dir_EXIF_GPS.tiff \
-	images/testfax3_bug_513.tiff
+	images/testfax3_bug_513.tiff \
+	images/32bpp-None.tiff
 
 PNMIMAGES = \
 	images/minisblack-1c-8b.pgm \
diff --git a/test/images/32bpp-None.tiff b/test/images/32bpp-None.tiff
new file mode 100644
index 0000000000000000000000000000000000000000..77f080fc0840497fe52be77bdc9afebf7d61dfb6
GIT binary patch
literal 13222
zcmeI2dvF!i9mjw7#@sw0BsY;q3l0eoR0#5_N)4hV1R7c;p;N1pXo9WaR4s^(iq#Q(
zx0PC*R-K9{2r^o2OSQqNRxRR86{n)ujx(ZDTKxmGs09HZ*?zvedv5mL+~@`3qfUOC
zPxkD4_w4ule&_t|HZ+W~wG*t@A~g^*izUnw#b(7tW<@GTHoIcX@|lX5ikT8t;5G#F
zygUx&@M2D*`62n~+p{ilX%lhac+MYOo8zqylt2;=g+VX`Dxn%i!B{v3YGEogKogt>
zXTp3~2#eurSO&MjN_YU)!&C4)Y=!MbG28R4@`8>z{foTs99rm6_Ue)a-sIARcT7pX
zcWl3ecRb}8teag?=(P<f@)iy5<6Sqj#JjV))ca#ix%cdGmEJ3j$9iv`J<Hp7$ywfe
zi(0%lTBdt1%{a<iGNSyR(!7|Sr`IxSfEPUI5wk};Gw&U<cQ%-97-+^{#Hwwitzp{1
zw3F!}dpNR{Vp|)BbBaBC%y#ZHyJLC!_OvCZzk|`>IL>%9Oolp;1{>j2Xa#BT0_aYI
zJhE+slm`36V|yCVT?^VuX|N0pqP=5E5@;~rn}P<XI}HvDHCP#Fuw5FgMT1R~yf^1H
zdhcKQeQ)=oX7BZudS8QAjVQmjByQzgv)8iJzyPxW(&19GrM%qnADVr5jv0TU^|Ml2
z%k(1C(fFVKHo%UsBi-g;-r8!mWecteU0ic*pvfY9V;Acw4ayHjH7GwQ4bmR`d;d5;
z=rp*QeSJUJ7Y$BFb7yp?L42V!nDT>Y@Iv{)lm;ujO|@0N2H!%1@`Jk<c53k2>hk;g
z#jS$t^;$PIARRtr_E5W7JI-S<FJ|i$vlCLg*I13c%+$g(-X_?&Oy@*&>hIXnLRi~w
zwq}jl3on>G{dDU1&O%RW(8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0
HcmV?d00001

diff --git a/test/tiff2rgba-32bpp-None-jpeg.sh b/test/tiff2rgba-32bpp-None-jpeg.sh
new file mode 100755
index 00000000..d435ccb9
--- /dev/null
+++ b/test/tiff2rgba-32bpp-None-jpeg.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Generated file, master is Makefile.am
+. ${srcdir:-.}/common.sh
+infile="$srcdir/images/32bpp-None.tiff"
+outfile="o-tiff2rgba-32bpp-None-jpeg.tiff"
+f_test_convert "${TIFF2RGBA} -B 255 -n" $infile $outfile
+f_tiffinfo_validate $outfile
diff --git a/test/tiffcp-32bpp-None-jpeg.sh b/test/tiffcp-32bpp-None-jpeg.sh
new file mode 100755
index 00000000..2aefa847
--- /dev/null
+++ b/test/tiffcp-32bpp-None-jpeg.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Generated file, master is Makefile.am
+. ${srcdir:-.}/common.sh
+infile="o-tiff2rgba-32bpp-None-jpeg.tiff"
+outfile="o-tiffcp-32bpp-None-jpeg-YCbCr.tiff"
+f_test_convert "${TIFFCP} -c jpeg" $infile $outfile
+f_tiffinfo_validate $outfile
diff --git a/test/tiffcrop-32bpp-None-jpeg.sh b/test/tiffcrop-32bpp-None-jpeg.sh
new file mode 100755
index 00000000..1a401285
--- /dev/null
+++ b/test/tiffcrop-32bpp-None-jpeg.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Generated file, master is Makefile.am
+. ${srcdir:-.}/common.sh
+infile="o-tiff2rgba-32bpp-None-jpeg.tiff"
+outfile="o-tiffcp-32bpp-None-jpeg-YCbCr.tiff"
+f_test_convert "${TIFFCROP} -c jpeg" $infile $outfile
+f_tiffinfo_validate $outfile