2017.05.11 17:35 "[Tiff] JPEG compressed RGB tiled TIFF with chroma subsampling", by Yakov Galka

2017.05.22 19:18 "Re: [Tiff] JPEG compressed RGB tiled TIFF with chroma subsampling", by Roger Leigh

On 22/05/2017 16:42, Yakov Galka wrote:

Dear Kemp,

On Mon, May 22, 2017 at 6:31 PM, Kemp Watson

> <kemp@objectivepathology.com <mailto:kemp@objectivepathology.com>> wrote:

Tiles/strips is a critical difference to many applications. If it

> was abstracted away, entire businesses would cease to exist - not a

in the least for geospatial, astronomy, or microscopy pesky detail applications.

It seems that you misunderstood me. I surely don't advocate abstracting tiles and strips away, like TIFFReadRGBAImage does.

Instead, I was talking about providing uniform interface for both of them, so that the interface for the tiles would read striped TIFFs too. Every libTIFF software I see has two separate code paths for tiles and strips. But strips are logically image-width sized tiles, and it would simplify everybody's life if libTIFF reflected that in the API.

Being able to use tiles in the API would be very nice. I certainly have to use two codepaths to cater for both possibilities as you say:

https://github.com/ome/ome-files-cpp/blob/master/lib/ome/files/tiff/IFD.cpp#L368

https://github.com/ome/ome-files-cpp/blob/master/lib/ome/files/tiff/IFD.cpp#L290

IIRC the main problem is the buffer packing arrangement for strips vs tiles when using an image size which isn't a multiple of 16. Tiles would overlap the image bounds on the x axis by sizex%16 unused pixels per row, but strips are contiguous runs. And then there's the special casing for bitspersample when it's not a multiple of 8. I recall this being incompletely specified in the 6.0 spec; I ended up packing the buffer according to what libtiff handled, and what other software seemed to expect as well.

That's not to say that libtiff couldn't handle the differences internally; it would have a cost for sure. But we're likely already paying the cost of the correct packing for strips/tiles *anyway*.

Regards,
Roger