changeset 510:ea451645a59e

add debug information in TiffReader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 19 Aug 2026 17:52:56 +0200
parents f8cd1ddb777c
children 469cb17be6aa
files Framework/TiffReader.cpp
diffstat 1 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/TiffReader.cpp	Wed Aug 19 16:37:30 2026 +0200
+++ b/Framework/TiffReader.cpp	Wed Aug 19 17:52:56 2026 +0200
@@ -26,6 +26,9 @@
 #include <Logging.h>
 #include <OrthancException.h>
 
+#include <boost/lexical_cast.hpp>
+
+
 namespace OrthancWSI
 {
   TiffReader::TiffReader(const std::string& path)
@@ -49,6 +52,44 @@
   }
 
 
+  static std::string DescribeTiffPlanarConfig(unsigned int value)
+  {
+    switch (value)
+    {
+      case PLANARCONFIG_CONTIG:
+        return "CONTIG";
+
+      case PLANARCONFIG_SEPARATE:
+        return "SEPARATE";
+
+      default:
+        return boost::lexical_cast<std::string>(value);
+    }
+  }
+
+
+  static std::string DescribeTiffPhotometry(unsigned int value)
+  {
+    switch (value)
+    {
+      case PHOTOMETRIC_RGB:
+        return "RGB";
+
+      case PHOTOMETRIC_PALETTE:
+        return "PALETTE";
+
+      case PHOTOMETRIC_YCBCR:
+        return "YCBCR";
+
+      case PHOTOMETRIC_CIELAB:
+        return "CIELAB";
+
+      default:
+        return boost::lexical_cast<std::string>(value);
+    }
+  }
+
+
   bool TiffReader::GetCurrentDirectoryInformation(ImageCompression& compression,
                                                   Orthanc::PixelFormat& pixelFormat,
                                                   Orthanc::PhotometricInterpretation& photometric)
@@ -103,7 +144,7 @@
           break;
 
         default:
-          LOG(ERROR) << "Unknown photometric interpretation in TIFF: " << photometricTiff;
+          LOG(WARNING) << "Unsupported photometric interpretation in TIFF: " << DescribeTiffPhotometry(photometricTiff);
           return false;
       }
     }
@@ -124,6 +165,10 @@
     }
     else
     {
+      LOG(WARNING) << "Unsupported TIFF layout: " << EnumerationToString(compression) << " with "
+                   << channels << " channels, " << bpp << " bpp, "
+                   << DescribeTiffPlanarConfig(planar) << " planar configuration, and "
+                   << DescribeTiffPhotometry(photometricTiff) << " photometry";
       return false;
     }