@@ -1675,6 +1675,33 @@ def test_tiff_ovr_43(tmp_path, both_endian):
1675
1675
assert cs == 642 , "did not get expected checksum"
1676
1676
1677
1677
1678
+ ###############################################################################
1679
+ # Test that we do not propagate PHOTOMETRIC=YCBCR on overviews when
1680
+ # COMPRESS_OVERVIEW != JPEG
1681
+
1682
+
1683
+ @pytest .mark .require_creation_option ("GTiff" , "JPEG" )
1684
+ @gdaltest .enable_exceptions ()
1685
+ def test_tiff_ovr_do_not_propagate_photometric_ycbcr_if_ovr_if_not_jpeg (tmp_path ):
1686
+
1687
+ tif_fname = str (tmp_path / "test.tif" )
1688
+
1689
+ ds = gdal .GetDriverByName ("GTiff" ).Create (
1690
+ tif_fname , 8 , 8 , 3 , options = ["COMPRESS=JPEG" , "PHOTOMETRIC=YCBCR" ]
1691
+ )
1692
+ ds .GetRasterBand (1 ).Fill (255 )
1693
+ ds .GetRasterBand (2 ).Fill (255 )
1694
+ ds .GetRasterBand (3 ).Fill (255 )
1695
+ ds = None
1696
+
1697
+ with gdal .Open (tif_fname , gdal .GA_Update ) as ds :
1698
+ with gdal .config_option ("COMPRESS_OVERVIEW" , "DEFLATE" ):
1699
+ ds .BuildOverviews ("NEAR" , [2 ])
1700
+
1701
+ with gdal .Open (tif_fname ) as ds :
1702
+ assert ds .GetRasterBand (1 ).GetOverview (0 ).ComputeRasterMinMax () == (255 , 255 )
1703
+
1704
+
1678
1705
###############################################################################
1679
1706
# Test that we can change overview block size through GDAL_TIFF_OVR_BLOCKSIZE configuration
1680
1707
# option
0 commit comments