Added compression and f32 support for TIFF encoding/decoding.
I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to choose either at their option.
f32 encoding/decoding support is added without additional byte alignment requirements. Removed 2-byte alignment requirement for u16 encoding/decoding. Added TIFF compression support.
CI seems to be failing because this exposes the tiff crate's Compressor type
I somehow missed this, just pushed changes that hide tiff crate's Compressor type.
@fintelia can you please take a look at this?
I've been taking a hiatus from most PR review and issue triage because I got burned out following the 0.25 release. Another reviewer might have a chance to review this at some point
@fintelia I hope you feel better soon!
This ideally should have been two PRs for f32 support and compression respectively
Alright, I'll split it up. It also seems to me like f32 support was simpler than the compression part.
I think Iv'e found an issue with either this PR or #2534. I started by forking the image-rs main branch and then I used the following commands to merge this PR into the branch x on my fork:
git remote add sunipkm https://github.com/sunipkm/image-rs.git
git fetch origin
git fetch sunipkm
git checkout origin/main
git checkout -b merge-tiff-compress
git merge sunipkm/tiff-compress
git push origin merge-tiff-compress
I then setup my application to use the merge-tiff-compress branch on my fork with the following:
image = { git = "https://github.com/maxall41/image.git", branch = "merge-tiff-compress" }
With this setup I am able to successfully load all of the tiff images in the test suite added in PR #2534. But with the attached image I get the following error while attempting to decode:
The encoder or decoder for Tiff does not support the color type `Unknown(32)`
Tiff info:
❯ tiffinfo reproduce.tif
TIFFReadDirectory: Warning, Unknown field with tag 50838 (0xc696) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 50839 (0xc697) encountered.
=== TIFF directory 0 ===
TIFF Directory at offset 0x8 (8)
Subfile Type: (0 = 0x0)
Image Width: 424 Image Length: 546
Bits/Sample: 32
Sample Format: IEEE floating point
Compression Scheme: None
Photometric Interpretation: min-is-black
Samples/Pixel: 1
Rows/Strip: 546
Planar Configuration: single image plane
ImageDescription: ImageJ=1.54p
min=0.0
max=1.0
Tag 50838: 12,22,14,20,8
Tag 50839: 73,74,73,74,112,114,111,112,0,0,0,4,0,83,0,108,0,105,0,99,0,101,0,95,0,76,0,97,0,98,0,101,0,108,0,99,0,108,0,97,0,115,0,115,0,32,0,49,0,85,0,110,0,105,0,113,0,117,0,101,0,78,0,97,0,109,0,101,0,116,0,114,0,117,0,101
Image to reproduce issue: https://drive.google.com/file/d/1qcnFq-LCde0SFxxuKNgCSnr4sq2OnpuS/view?usp=sharing
I am able to load this image in ImageJ2/Fiji and Apple Preview.
@maxall41 This PR adds RGB and RGBA 32-bit floating point support, but notably doesn't add support for single-channel floating point images like the one you attached.
Though it would probably be good to adjust the error message...
@fintelia Ah that explains it. I might write a PR to add support...
Just made a PR: #2536