From a14b7be81cd754e825190d2bf979c503c088fdbc Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 8 Dec 2024 17:07:24 +0100 Subject: [PATCH] GTiff/COG writer: add hint about NBITS creation option to specify to be compatible of PREDICTOR creation option Fixes #11457 --- frmts/gtiff/gtiffdataset_write.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frmts/gtiff/gtiffdataset_write.cpp b/frmts/gtiff/gtiffdataset_write.cpp index bd4b1c9f421b..23ead97bca5f 100644 --- a/frmts/gtiff/gtiffdataset_write.cpp +++ b/frmts/gtiff/gtiffdataset_write.cpp @@ -5323,15 +5323,23 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, else #endif { + const int nBITSHint = (l_nBitsPerSample < 8) ? 8 + : (l_nBitsPerSample < 16) ? 16 + : (l_nBitsPerSample < 32) ? 32 + : 64; ReportError(pszFilename, CE_Failure, CPLE_AppDefined, #ifdef HAVE_PREDICTOR_2_FOR_64BIT "PREDICTOR=2 is only supported with 8/16/32/64 " - "bit samples." + "bit samples. You can specify the NBITS=%d " + "creation option to promote to the closest " + "supported bits per sample value.", #else "PREDICTOR=2 is only supported with 8/16/32 " - "bit samples." + "bit samples. You can specify the NBITS=%d " + "creation option to promote to the closest " + "supported bits per sample value.", #endif - ); + nBITSHint); } return nullptr; }