libtiff: tiffcp: replace PHOTOMETRIC_YCBCR with PHOTOMETRIC_RGB when outputing to compression != JPEG (refs #571)

From 2cccf6d75bfe962d9b6e5c4b856c774a8a92a952 Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Sat, 7 Oct 2023 00:40:50 +0200
Subject: [PATCH] tiffcp: replace PHOTOMETRIC_YCBCR with PHOTOMETRIC_RGB when
 outputing to compression != JPEG (refs #571)

---
 tools/tiffcp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/tiffcp.c b/tools/tiffcp.c
index 8a660481..d2dd6b17 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -893,7 +893,12 @@ static int tiffcp(TIFF *in, TIFF *out)
                      samplesperpixel == 1 ? PHOTOMETRIC_LOGL
                                           : PHOTOMETRIC_LOGLUV);
     else
-        CopyTag(TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT);
+    {
+        if (input_photometric == PHOTOMETRIC_YCBCR)
+            TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
+        else
+            CopyTag(TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT);
+    }
     if (fillorder != 0)
         TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
     else