haraldk / TwelveMonkeys

TwelveMonkeys ImageIO: Additional plug-ins and extensions for Java's ImageIO
https://haraldk.github.io/TwelveMonkeys/
BSD 3-Clause "New" or "Revised" License
1.91k stars 315 forks source link

TIFF: Add support for SAMPLEFORMAT_COMPLEXINT/SAMPLEFORMAT_COMPLEXIEEEFP #1026

Closed don-vip closed 1 month ago

don-vip commented 1 month ago

Fixes #884

I didn't add tests in the commit (although I wrote one) because the smallest sample file I could find is 25 Mb... Let me know if I should add it anyway:

--- a/imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageReaderTest.java
+++ b/imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/TIFFImageReaderTest.java
@@ -194,7 +194,9 @@ public class TIFFImageReaderTest extends ImageReaderAbstractTest<TIFFImageReader
                 new TestData(getClassLoaderResource("/tiff/planar-yuv420-jpeg-uncompressed.tif"), new Dimension(256, 64)), // YCbCr, JPEG coefficients, uncompressed, striped
                 new TestData(getClassLoaderResource("/tiff/planar-yuv420-jpeg-lzw.tif"), new Dimension(256, 64)), // YCbCr, JPEG coefficients,LZW compressed, striped
                 new TestData(getClassLoaderResource("/tiff/planar-yuv410-jpeg-uncompressed.tif"), new Dimension(256, 64)), // YCbCr, JPEG coefficients, uncompressed, striped
-                new TestData(getClassLoaderResource("/tiff/planar-yuv410-jpeg-lzw.tif"), new Dimension(256, 64)) // YCbCr, JPEG coefficients,LZW compressed, striped
+                new TestData(getClassLoaderResource("/tiff/planar-yuv410-jpeg-lzw.tif"), new Dimension(256, 64)), // YCbCr, JPEG coefficients,LZW compressed, striped
+                // Complex sample formats
+                new TestData(getClassLoaderResource("/tiff/CAPELLA_C13_SM_SLC_VV_20240924045643_20240924045645.tif"), new Dimension(1871, 5026)) // Complex signed integer
         );
     }
haraldk commented 1 month ago

Thanks for providing this! 👍🏻

So, no special handling of these complex types are needed? 😮

I will add a full review as soon as possible, I'm back in the office from Monday. But looks like this can be safely merged.

Can you send the sample file? Maybe we can trim it a bit in a hex editor, if it's uncompressed or tiled/striped. But I agree, 25 MB for testing this is a but much.

UPDATE: I see you have linked the file in your original description, never mind. 😀

don-vip commented 1 month ago

Thanks for the review! Honestly I don't know if more changes are needed, those simple changes were enough for me to read the sample file.

haraldk commented 1 month ago

I merged the PR. Thanks again!