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

Ignore compression value from BMP info dictionary when saving as TIFF #6231

Merged
merged 1 commit into from May 20, 2022

Conversation

radarhere
Copy link
Member

Helps #6230

BmpImagePlugin sets the info dictionary "compression" to an integer.

COMPRESSIONS = {"RAW": 0, "RLE8": 1, "RLE4": 2, "BITFIELDS": 3, "JPEG": 4, "PNG": 5}
for k, v in COMPRESSIONS.items():
vars()[k] = v

file_info["compression"] = self.RAW

self.info["compression"] = file_info["compression"]

However, when TiffImagePlugin is saving, it expects a string.

compression = encoderinfo.get("compression", im.info.get("compression"))
if compression is None:
compression = "raw"
elif compression == "tiff_jpeg":
# OJPEG is obsolete, so use new-style JPEG compression instead
compression = "jpeg"
elif compression == "tiff_deflate":
compression = "tiff_adobe_deflate"

This leads to an error. This PR instead ignores integer compression values from the info dictionary when saving as a TIFF.

@radarhere radarhere changed the title Ignore compression value from BMP info dictionary Ignore compression value from BMP info dictionary when saving as TIFF Apr 20, 2022
@hugovk hugovk merged commit 33f00c9 into python-pillow:main May 20, 2022
@radarhere radarhere deleted the bmp_compression branch May 20, 2022 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants