Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Pillow 11.0.0 throws ValueError when saving GIF #8493

Closed
ArcasCZ opened this issue Oct 23, 2024 · 5 comments · Fixed by #8494
Closed

Pillow 11.0.0 throws ValueError when saving GIF #8493

ArcasCZ opened this issue Oct 23, 2024 · 5 comments · Fixed by #8494
Labels

Comments

@ArcasCZ
Copy link

ArcasCZ commented Oct 23, 2024

What did you do?

I'm saving a GIF created from series of PNG.

What did you expect to happen?

The GIF is created.

What actually happened?

Traceback (most recent call last):
  File "/root/.local/lib/python3.12/site-packages/discord/ext/commands/core.py", line 235, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/strawberry-py/modules/fun/fun/module.py", line 437, in lick
    with BytesIO() as image_binary:
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/PIL/Image.py", line 2605, in save
    save_handler(self, fp, filename)
  File "/usr/local/lib/python3.12/site-packages/PIL/GifImagePlugin.py", line 774, in _save_all
    _save(im, fp, filename, save_all=True)
  File "/usr/local/lib/python3.12/site-packages/PIL/GifImagePlugin.py", line 787, in _save
    if not save_all or not _write_multiple_frames(im, fp, palette):
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/PIL/GifImagePlugin.py", line 700, in _write_multiple_frames
    background_im.putpalette(im_frames[0].im.palette)
  File "/usr/local/lib/python3.12/site-packages/PIL/Image.py", line 2103, in putpalette
    self.load()  # install new palette
    ^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/PIL/Image.py", line 909, in load
    self.im.putpalette(self.palette.mode, mode, arr)
ValueError: invalid palette size

This happens only on Pillow 11.0.0 with disposal=2.

What are your OS, Python and Pillow versions?

  • OS: Windows 11 / Ubuntu 24.04.1 LTS
  • Python: 3.12
  • Pillow: 11.0.0
--------------------------------------------------------------------
Pillow 11.0.0
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
--------------------------------------------------------------------
Python executable is C:\Program Files\Python312\python.exe
System Python files loaded from C:\Program Files\Python312
--------------------------------------------------------------------
Python Pillow modules loaded from C:\Program Files\Python312\Lib\site-packages\PIL
Binary Pillow modules loaded from C:\Program Files\Python312\Lib\site-packages\PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.0.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.3
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.4.0
--- JPEG support ok, compiled for libjpeg-turbo 3.0.4
--- 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 not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
*** XCB (X protocol) support not installed
--------------------------------------------------------------------

https://github.com/strawberry-py/strawberry-fun/blob/main/fun/module.py#L437

The error happens only on 11.0.0 verison, previous 10.4.0 works fine.
I assume it might be related to #8366

@radarhere
Copy link
Member

radarhere commented Oct 23, 2024

Could we get a copy of the PNG images you are using as input?

@radarhere radarhere changed the title PILLOW 11.0.0 throws ValueError with GIF Pillow 11.0.0 throws ValueError with GIF Oct 23, 2024
@radarhere radarhere added the GIF label Oct 23, 2024
@radarhere radarhere changed the title Pillow 11.0.0 throws ValueError with GIF Pillow 11.0.0 throws ValueError when saving GIF Oct 23, 2024
@ArcasCZ
Copy link
Author

ArcasCZ commented Oct 24, 2024

Hi,

it happens with all images saved in the ./fun/data folder, e.g. https://github.com/strawberry-py/strawberry-fun/tree/main/fun/data/lick

@radarhere
Copy link
Member

I've created #8494

@ArcasCZ
Copy link
Author

ArcasCZ commented Nov 15, 2024

Hi,
is there any ETA for this fix?

@hugovk
Copy link
Member

hugovk commented Nov 15, 2024

Assuming it's reviewed and merged it'll be in next release on 2nd January.

You can help by reviewing the PR and testing it to confirm if it fixes your problem.

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

Successfully merging a pull request may close this issue.

3 participants