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

Fixed saving multiple 1 mode frames to GIF #7181

Merged
merged 1 commit into from Jun 6, 2023
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
13 changes: 13 additions & 0 deletions Tests/test_file_gif.py
Expand Up @@ -252,6 +252,19 @@ def test_roundtrip_save_all(tmp_path):
assert reread.n_frames == 5


def test_roundtrip_save_all_1(tmp_path):
out = str(tmp_path / "temp.gif")
im = Image.new("1", (1, 1))
im2 = Image.new("1", (1, 1), 1)
im.save(out, save_all=True, append_images=[im2])

with Image.open(out) as reloaded:
assert reloaded.getpixel((0, 0)) == 0

reloaded.seek(1)
assert reloaded.getpixel((0, 0)) == 255


@pytest.mark.parametrize(
"path, mode",
(
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/GifImagePlugin.py
Expand Up @@ -879,7 +879,7 @@ def _get_palette_bytes(im):
:param im: Image object
:returns: Bytes, len<=768 suitable for inclusion in gif header
"""
return im.palette.palette
return im.palette.palette if im.palette else b""


def _get_background(im, info_background):
Expand Down