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

Pass SAMPLEFORMAT to libtiff #5848

merged 1 commit into from Dec 28, 2021

Pass SAMPLEFORMAT to libtiff #5848

merged 1 commit into from Dec 28, 2021


Copy link

@radarhere radarhere commented Nov 22, 2021

Resolves #5843

SAMPLEFORMAT is currently in the blocklist when saving with libtiff.

blocklist += [

The explanation is

# SAMPLEFORMAT is determined by the image format and should not be copied
# from legacy_ifd.

But SAMPLEFORMAT doesn't only come from the user. It can also be set by TiffImagePlugin, according to the image format.

# mode => rawmode, byteorder, photometrics,
# sampleformat, bitspersample, extra
"1": ("1", II, 1, 1, (1,), None),
"L": ("L", II, 1, 1, (8,), None),
"LA": ("LA", II, 1, 1, (8, 8), 2),
"P": ("P", II, 3, 1, (8,), None),
"PA": ("PA", II, 3, 1, (8, 8), 2),
"I": ("I;32S", II, 1, 2, (32,), None),
"I;16": ("I;16", II, 1, 1, (16,), None),
"I;16S": ("I;16S", II, 1, 2, (16,), None),
"F": ("F;32F", II, 1, 3, (32,), None),

if format != 1:
ifd[SAMPLEFORMAT] = format

So this PR removes SAMPLEFORMAT from blocklist, allowing the value to be passed to libtiff by TiffImagePlugin's code - but also adding other code to still not allow the user to set it.

@radarhere radarhere added the TIFF label Nov 22, 2021
@hugovk hugovk merged commit 1806cf5 into python-pillow:main Dec 28, 2021
49 checks passed
@radarhere radarhere deleted the sampleformat branch Dec 28, 2021
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.

2 participants