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

Pillow no longer reads grayscale multi-frame gifs #6084

Closed
FirefoxMetzger opened this issue Feb 22, 2022 · 1 comment · Fixed by #6086
Closed

Pillow no longer reads grayscale multi-frame gifs #6084

FirefoxMetzger opened this issue Feb 22, 2022 · 1 comment · Fixed by #6086
Labels

Comments

@FirefoxMetzger
Copy link
Contributor

The following breaks in pillow 9.0.1 but works fine if I downgrade to pillow 8.4.0. My guess is that the new loader that converts to RGB/RGBA when seeking doesn't account for the possibility of a grayscale GIF.

from PIL import Image
import numpy as np

img = Image.open("gray_test.gif")
im1 = np.asarray(img)  # just showing that the first frame works
img.seek(2)  # break

Stack Trace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38\lib\site-packages\PIL\GifImagePlugin.py", line 133, in seek
    self._seek(f)
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38\lib\site-packages\PIL\GifImagePlugin.py", line 151, in _seek
    self.load()
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38\lib\site-packages\PIL\ImageFile.py", line 264, in load
    self.load_end()
  File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python38\lib\site-packages\PIL\GifImagePlugin.py", line 371, in load_end
    self.im.putpalettealpha(self._frame_transparency, 0)
ValueError: image has no palette

Picture for testing:

gray_test

@radarhere
Copy link
Member

I've created PR #6086 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