Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #5843

SAMPLEFORMAT is currently in the blocklist when saving with libtiff.

blocklist += [
REFERENCEBLACKWHITE,
SAMPLEFORMAT,

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.

SAVE_INFO = {
# 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
@radarhere radarhere deleted the sampleformat branch December 28, 2021 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect image data and type after TIFF compression

2 participants