2020.07.06 13:56 "Re: [Tiff] TIFF Tile Size and TileByteCounts", by Olivier Paquet
I have a question regarding the relation of tile size (TileWidth x TileLength) and the number of bytes to be read from file (TileByteCounts). According the tags as listed below, the size of each tile is 256 x 256 = 65536 bytes. But the number of bytes per tile ( TileByteCounts ) are either smaller (e.g. 149, 6930,... bytes) or bigger (e.g. 74613, 128520,..... bytes).
Your file also has:
- '258 (0x102: BitsPerSample): 16 (1 Short)'
which means 2 bytes per pixel. So 256 x 256 x 2 = 131072.
Hence, my question is what e.g. the value 149 means exactly and how to create a 256 x 256 bytes tile out of only 149 bytes.
It is the size of the data for the tile in the file, on disk. In your case, with:
- '259 (0x103: Compression): 8 (1 Short)'
the tiles are compressed, which is why they are smaller than you expect. They could probably also be slightly larger if they compress really poorly. How much depends on the specific compression algorithm. The data needs to be decompressed after being read, which should yield the expected 131072 bytes. Libtiff can do all of that for you so you normally shouldn't have to care about the tile offset and tile byte count tags. You do need to figure out the uncompressed tile size to provide a large enough buffer for it, and generally to know how to interpret the data (eg. in 16-bit chunks in your case).