mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
Merge pull request #6231 from radarhere/bmp_compression
Ignore compression value from BMP info dictionary when saving as TIFF
This commit is contained in:
commit
33f00c9ca8
|
@ -715,6 +715,13 @@ class TestFileTiff:
|
||||||
with Image.open(outfile) as reloaded:
|
with Image.open(outfile) as reloaded:
|
||||||
assert reloaded.info["icc_profile"] == icc_profile
|
assert reloaded.info["icc_profile"] == icc_profile
|
||||||
|
|
||||||
|
def test_save_bmp_compression(self, tmp_path):
|
||||||
|
with Image.open("Tests/images/hopper.bmp") as im:
|
||||||
|
assert im.info["compression"] == 0
|
||||||
|
|
||||||
|
outfile = str(tmp_path / "temp.tif")
|
||||||
|
im.save(outfile)
|
||||||
|
|
||||||
def test_discard_icc_profile(self, tmp_path):
|
def test_discard_icc_profile(self, tmp_path):
|
||||||
outfile = str(tmp_path / "temp.tif")
|
outfile = str(tmp_path / "temp.tif")
|
||||||
|
|
||||||
|
|
|
@ -1559,7 +1559,13 @@ def _save(im, fp, filename):
|
||||||
|
|
||||||
encoderinfo = im.encoderinfo
|
encoderinfo = im.encoderinfo
|
||||||
encoderconfig = im.encoderconfig
|
encoderconfig = im.encoderconfig
|
||||||
compression = encoderinfo.get("compression", im.info.get("compression"))
|
try:
|
||||||
|
compression = encoderinfo["compression"]
|
||||||
|
except KeyError:
|
||||||
|
compression = im.info.get("compression")
|
||||||
|
if isinstance(compression, int):
|
||||||
|
# compression value may be from BMP. Ignore it
|
||||||
|
compression = None
|
||||||
if compression is None:
|
if compression is None:
|
||||||
compression = "raw"
|
compression = "raw"
|
||||||
elif compression == "tiff_jpeg":
|
elif compression == "tiff_jpeg":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user