Modification to resolution handling in TIFF reader / writer#4185
Modification to resolution handling in TIFF reader / writer#4185ruven wants to merge 3 commits intolibvips:masterfrom
Conversation
…ithin TIFF file. TIFF writer now only sets resolution if this is really known, rather than setting a default value. The resolution of sub-resolution layers within a pyramid TIFF are now scaled depending on the sub-sampling of that layer.
|
Hi Ruven, Sorry, I don't think this is going to work. You can't use I think the correct fix would be to move xres/yres out of the vips image header and store it as generic metadata. Those values can be unset, so you could represent "no data available". It would break a lot of stuff though, so ... something for libvips 9.0. |
|
Yeah, I was a bit hesitant to make a pull request for this for as I was unsure of the wider impact. That's also why the I put the setting of the default to zero in a separate commit. However, having said that, it works perfectly for loading and saving to TIFF. And I'm not sure it's as big a problem as you think because:
Of course there may be things I've missed! |
|
I think those tests are trying to allow very small but still positive resolutions. I remember we used to have zero res in output file sometimes, and it caused a lot of problems downstream, including crashes in some apps. That was a good while ago, mind you. |
That's a common thing in downstream code working with eg. slide output, where resolution is usually expressed as microns per pixel. |
Vips currently sets a default X and Y resolution of 1.0 if no resolution information is found within an image file. Rather than write "fake" resolution information to a TIFF, this pull request modifies things so that the TIFF X/Y resolution is only written if this value is really known.
Also when writing a multi-resolution pyramid TIFF, identical resolution information is currently set for each layer in the pyramid. This information is now scaled by the sub-sampling factor so that the resolution now correctly represents what the resolution really is for each layer.
A similar change has also be made for PNG writing.