Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated libtiff to 4.2.0 #5153

merged 2 commits into from Dec 30, 2020


Copy link

@radarhere radarhere commented Dec 29, 2020

Resolves #5157

Updated libtiff to 4.2.0, adding a setting to 'winbuild/tiff.opt' because of (later simplified).

However, from the first commit here, you can see that a test fails.

Investigating, it is failing specifically because of

tc(TiffImagePlugin.IFDRational(4, 7), TiffTags.RATIONAL, True),

libtiff 4.2.0 added the 'Rational2Double' block in this code (if you're interested, it was part of -

tv_size = _TIFFDataSize(fip->field_type);
/*--: Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size. */
if (fip->field_type == TIFF_RATIONAL || fip->field_type == TIFF_SRATIONAL) {
	tv_size = _TIFFSetGetFieldSize(fip->set_field_type);
if (tv_size == 0) {
	status = 0;
	TIFFErrorExt(tif->tif_clientdata, module,
		"%s: Bad field type %d for \"%s\"",
		tif->tif_name, fip->field_type,
	goto end;

These lines are returning zero for tv_size - I conclude it is because fip->set_field_type is not properly set from in TIFFMergeFieldInfo.

tp->set_field_type =

This is because _TIFFSetGetType has a few conditions to match against TIFF_RATIONAL -

if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0)
else if (count == 1 && passcount == 0) {
else if (count >= 1 && passcount == 0) {
else if (count == TIFF_VARIABLE && passcount == 1) {
else if (count == TIFF_VARIABLE2 && passcount == 1) {

but none involve count (readcount in TiffDecode.c) being zero.

int readcount = 0;

So this PR changes that value, and the test now passes.

This also then fixes python-pillow/pillow-wheels#180.

@radarhere radarhere added the TIFF label Dec 29, 2020
@radarhere radarhere changed the title Corrected use of TIFFMergeFieldInfo for libtiff 4.2.0 Updated libtiff to 4.2.0 Dec 30, 2020
hugovk approved these changes Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

testsuite fails with libtiff 4.2.0
2 participants