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

Always save TIFF with contiguous planar configuration #5973

Merged
merged 1 commit into from Mar 27, 2022
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
11 changes: 11 additions & 0 deletions Tests/test_file_tiff.py
Expand Up @@ -594,6 +594,17 @@ def test_tiled_planar_raw(self):
with Image.open(infile) as im:
assert_image_equal_tofile(im, "Tests/images/tiff_adobe_deflate.png")

def test_planar_configuration_save(self, tmp_path):
infile = "Tests/images/tiff_tiled_planar_raw.tif"
with Image.open(infile) as im:
assert im._planar_configuration == 2

outfile = str(tmp_path / "temp.tif")
im.save(outfile)

with Image.open(outfile) as reloaded:
assert_image_equal_tofile(reloaded, infile)

def test_palette(self, tmp_path):
def roundtrip(mode):
outfile = str(tmp_path / "temp.tif")
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/TiffImagePlugin.py
Expand Up @@ -1528,7 +1528,7 @@ def _save(im, fp, filename):
libtiff = WRITE_LIBTIFF or compression != "raw"

# required for color libtiff images
ifd[PLANAR_CONFIGURATION] = getattr(im, "_planar_configuration", 1)
ifd[PLANAR_CONFIGURATION] = 1

ifd[IMAGEWIDTH] = im.size[0]
ifd[IMAGELENGTH] = im.size[1]
Expand Down