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

GIF optimizer acts wrongly with black pixels when disposal=2 #8222

Closed
lucach opened this issue Jul 10, 2024 · 1 comment · Fixed by #8366
Closed

GIF optimizer acts wrongly with black pixels when disposal=2 #8222

lucach opened this issue Jul 10, 2024 · 1 comment · Fixed by #8366
Labels

Comments

@lucach
Copy link

lucach commented Jul 10, 2024

What did you do?

  • Create a GIF with these two identically sized (250x217) frames: green.png and red.png
    green
    red
from PIL import Image

green = Image.open("green.png")
red = Image.open("red.png")
green.save("opt.gif", save_all=True, append_images=[red], disposal=2, loop=0, duration=500) 

What did you expect to happen?

Pillow should create this GIF:

no_opt

What actually happened?

Pillow actually creates this GIF, with the second frame "missing" two pixels in height, which get shown as transparent:
opt

> identify opt.gif
opt.gif[0] GIF 250x217 250x217+0+0 8-bit sRGB 32c 0.000u 0:00.000
opt.gif[1] GIF 250x215 250x217+0+0 8-bit sRGB 64c 5237B 0.000u 0:00.000

What I discovered so far:

  • If the black color gets changed to a black-ish color (e.g., rgb(2, 0, 0)), the issue disappears
  • If the disposal method is not 2, the issue disappears
  • If optimize=False, the issue disappears (see the no_opt.gif created above in the "expect to happen" section)

This problem seems related, but not identical, to #8003.

What are your OS, Python and Pillow versions?

  • OS: macOS 14.5
  • Python: 3.12.3
  • Pillow: 10.4.0
--------------------------------------------------------------------
Pillow 10.4.0
Python 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)]
--------------------------------------------------------------------
Python executable is /Users/lucach/Library/Caches/pypoetry/virtualenvs/pytamaro-5GgIxOWM-py3.12/bin/python
Environment Python files loaded from /Users/lucach/Library/Caches/pypoetry/virtualenvs/pytamaro-5GgIxOWM-py3.12
System Python files loaded from /opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12
--------------------------------------------------------------------
Python Pillow modules loaded from /Users/lucach/Library/Caches/pypoetry/virtualenvs/pytamaro-5GgIxOWM-py3.12/lib/python3.12/site-packages/PIL
Binary Pillow modules loaded from /Users/lucach/Library/Caches/pypoetry/virtualenvs/pytamaro-5GgIxOWM-py3.12/lib/python3.12/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 10.4.0
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.4.0
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 3.0.3
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1
--- LIBTIFF support ok, loaded 4.6.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.14, harfbuzz 8.5.0
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
@radarhere
Copy link
Member

I've created #8366 to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants