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

ValueError: images do not match #7777

Closed
alanhamlett opened this issue Feb 3, 2024 · 8 comments · Fixed by #7779
Closed

ValueError: images do not match #7777

alanhamlett opened this issue Feb 3, 2024 · 8 comments · Fixed by #7779
Labels

Comments

@alanhamlett
Copy link

alanhamlett commented Feb 3, 2024

Without changing code, only upgrading from 10.1.0 to 10.2.0, started getting this error when generating animated GIFs:

  File "wakatime/insights/utils.py", line 481, in get_animated_insight
    images[0].save(out, format="gif", append_images=images[1:-1], save_all=True, duration=80, loop=0)
  File "venv/lib/python3.10/site-packages/PIL/Image.py", line 2439, in save
    save_handler(self, fp, filename)
  File "venv/lib/python3.10/site-packages/PIL/GifImagePlugin.py", line 704, in _save_all
    _save(im, fp, filename, save_all=True)
  File "venv/lib/python3.10/site-packages/PIL/GifImagePlugin.py", line 715, in _save
    if not save_all or not _write_multiple_frames(im, fp, palette):
  File "venv/lib/python3.10/site-packages/PIL/GifImagePlugin.py", line 671, in _write_multiple_frames
    diff_frame.paste(fill, mask=ImageOps.invert(mask))
  File "venv/lib/python3.10/site-packages/PIL/Image.py", line 1738, in paste
    self.im.paste(im, box, mask.im)
ValueError: images do not match
  • OS: Linux
  • Python: Python 3.10.12
  • Pillow: pillow==10.2.0
@hugovk
Copy link
Member

hugovk commented Feb 3, 2024

Thank you for reporting an issue.

Please include a self-contained, copy-pastable example that generates the issue if possible. Be concise with code posted. Guidelines on how to provide a good bug report:

Bug reports which follow these guidelines are easier to diagnose, and are often handled much more quickly.

Please include code that reproduces the issue and whenever possible, an image that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.

The best reproductions are self-contained scripts with minimal dependencies.

@alanhamlett
Copy link
Author

Looks like this commit is the culprit: 55c5587

@radarhere
Copy link
Member

Yes, that would be the cause - but rather than just undoing that change, it would be better to adjust it, to both reduce filesize and to fix your problem. The quickest way of understanding how to do that would be for you to post a self-contained example of your problem.

@alanhamlett
Copy link
Author

Here's a repo to reproduce the bug:
https://github.com/alanhamlett/pillow-issue-7777

@radarhere
Copy link
Member

Thanks.

0.png, 4.png and 5.png are 120px wide.
1.png, 2.png and 3.png are 108px wide.

The images you are using to create your GIF are not all the same size. So, as error says, the images do not match.

If you change them to all be the same size, the error goes away.

@alanhamlett
Copy link
Author

Got it, so it should have raised that exception in previous versions too. Thanks!

@alanhamlett
Copy link
Author

Actually, looks like animated GIF format supports images of different sizes. Should Pillow also?

@radarhere
Copy link
Member

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

3 participants