TIFF: only adjust strip/tile byte counts for uncompressed data#4444
Conversation
sbesson
left a comment
There was a problem hiding this comment.
Confirmed that using the sample file of the accompanying issue showinf fails with Bio-Formats 8.5.0 with an io.airlift.compress.MalformedInputException while decompressing the tile.
With this PR included, the reading of the metadata and pixel data works as expected
sbesson@Sebastien-GS-MacBook-Pro-2025 bioformats % ./tools/showinf ~/Downloads/test1.tif -autoscale
Checking file format [Tagged Image File Format]
Initializing reader
TiffDelegateReader initializing /Users/sbesson/Downloads/test1.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
Initialization took 0.034s
Reading core metadata
filename = /Users/sbesson/Downloads/test1.tif
Series count = 1
Series #0 :
Image count = 1
RGB = false (1)
Interleaved = false
Indexed = false (false color)
Width = 128
Height = 128
SizeZ = 1
SizeT = 1
SizeC = 1
Tile size = 128 x 128
Thumbnail size = 128 x 128
Endianness = intel (little)
Dimension order = XYCZT (certain)
Pixel type = uint16
Valid bits per pixel = 16
Metadata complete = true
Thumbnail series = false
-----
Plane #0 <=> Z 0, C 0, T 0
Reading pixel data (0-0)
Read 1/1 planes (100%)
[done]
0.028s elapsed (28.0ms per plane)
Launching image viewer
Reading global metadata
BitsPerSample: 16
Color mode: grayscale
Compression: Zstandard
DateTime: 2026:06:05 17:25:50
ImageJ: 1.11a
ImageLength: 128
ImageWidth: 128
MetaDataPhotometricInterpretation: Monochrome
MetaMorph: no
NumberOfChannels: 1
PhotometricInterpretation: BlackIsZero
SamplesPerPixel: 1
Software: tiffwrite_rs
TileByteCounts: 16384
TileLength: 128
TileOffsets: 16
TileWidth: 128
Unit: micron
hyperstack: true
loop: false
Reading metadata
The nightly repository builds have been passing with this change - https://bf-testing-results.s3.amazonaws.com/2026/2026-06-23/build-status.log.
Before merging, we should ensure this scenario is covered either by some unit test and/or by adding a representative sample to the curated QA repository to prevent future regression.
|
|
sbesson
left a comment
There was a problem hiding this comment.
The synthetic samples was successfully included in the nightly repository builds - https://bf-testing-results.s3.amazonaws.com/2026/2026-06-24/tiff.log
Fixes #4442.
Without this change,
showinfon the TIFF file linked to #4442 throws:tiffdumpreports:As I believe we do have examples of TIFF variants (Zeiss LSM?) that store uncompressed strips with byte counts that do not reflect the bytes per pixel, I did not remove the correction in line 778, but it should now be bypassed for compressed strips/tiles. With this change,
showinfon the test file opens the image without error.