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

Replaced tiff_deflate with tiff_adobe_deflate compression when saving TIFF images #5343

Merged
merged 1 commit into from Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions Tests/test_file_libtiff.py
Expand Up @@ -471,6 +471,14 @@ def test_tiff_jpeg_compression(self, tmp_path):
with Image.open(out) as reloaded:
assert reloaded.info["compression"] == "jpeg"

def test_tiff_deflate_compression(self, tmp_path):
im = hopper("RGB")
out = str(tmp_path / "temp.tif")
im.save(out, compression="tiff_deflate")

with Image.open(out) as reloaded:
assert reloaded.info["compression"] == "tiff_adobe_deflate"

def test_quality(self, tmp_path):
im = hopper("RGB")
out = str(tmp_path / "temp.tif")
Expand Down
2 changes: 2 additions & 0 deletions src/PIL/TiffImagePlugin.py
Expand Up @@ -1442,6 +1442,8 @@ def _save(im, fp, filename):
elif compression == "tiff_jpeg":
# OJPEG is obsolete, so use new-style JPEG compression instead
compression = "jpeg"
elif compression == "tiff_deflate":
compression = "tiff_adobe_deflate"

libtiff = WRITE_LIBTIFF or compression != "raw"

Expand Down