fix(tiff): care with missing rowsperstrip#5160
fix(tiff): care with missing rowsperstrip#5160lgritz merged 2 commits intoAcademySoftwareFoundation:mainfrom
Conversation
According to the TIFF spec, TIFF files with a missing rowsperstrip should assume the whole image is one strip. Related (found in debugging): add a DASSERT to help debug if fmath.h's round_to_multiple() is given an invalid denominator. Signed-off-by: Larry Gritz <lg@larrygritz.com>
| if (!m_spec.tile_width) { | ||
| TIFFGetField(m_tif, TIFFTAG_ROWSPERSTRIP, &m_rowsperstrip); | ||
| if (m_rowsperstrip > 0) | ||
| if (m_rowsperstrip > 0) { |
There was a problem hiding this comment.
I think we should also cap the m_rowsperstrip to the height of the image in all cases since downstream computations and memory allocations use the value too.
There was a problem hiding this comment.
Good suggestion. Done.
There was a problem hiding this comment.
Hmm, is there a reason not to clamp the value before setting the tiff:RowsPerStrip attribute value too?
There was a problem hiding this comment.
Yes, two reasons:
(1) The attribute should reflect what's actually in the file (for the sake of iinfo -v and the like), and there's nothing invalid about having it larger than the number of scanlines (just like happens for the last strip any time the strip size does not evenly divide into the height);
(2) I want it to make its way to the output image and be set there as well, so that something like iconvert in.tif out.tif will be as close as possible to cp in.tif out.tif and not change TIFF tag values that are perfectly legal.
Signed-off-by: Larry Gritz <lg@larrygritz.com>
According to the TIFF spec, TIFF files with a missing rowsperstrip should assume the whole image is one strip.
Somewhat related (found in debugging): add a DASSERT to help debug if fmath.h's round_to_multiple() is given an invalid denominator.