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: multiple comment blocks for a frame are run together #6293

Closed
raygard opened this issue May 13, 2022 · 2 comments · Fixed by #6294
Closed

GIF: multiple comment blocks for a frame are run together #6293

raygard opened this issue May 13, 2022 · 2 comments · Fixed by #6294
Labels

Comments

@raygard
Copy link
Contributor

raygard commented May 13, 2022

What did you do?

Read a GIF file with two or more comments in a single frame

What did you expect to happen?

They would somehow be kept separate in the .info dict

What actually happened?

The comments are run together, e.g. separate comments foo and bar become foobar

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.10.4
  • Pillow: 9.1.0

Example image:

multiple_comments

from PIL import Image
with Image.open("multiple_comments.gif") as im:
    print(f'{im.info["comment"]=}')

prints

im.info["comment"]=b'Test comment 1Test comment 2'

I made PR #6294 to address this, that will separate the comments with \r\n.

I admit that such cases are rare, but I have a few found in the wild. Unfortunately most of them have the multiple comments after the last image block, and at present I see no way in Pillow to access comments beyond the last image block. I do have one with 10 comment blocks before the image, a logo from my former employer:

b6483cc24863f387173dd6fb5a150ede_image003

@radarhere
Copy link
Member

I tried to see what exiftool did, but it only returns the first comment.

$ exiftool relayhealth.gif | grep Comment
Comment                         : Author:

https://www.metadata2go.com/, https://exifdata.com/ and https://jimpl.com/ do the same.

If I try ImageMagick, identify -verbose relayhealth.gif, I get only "Title:"

So my quest to see if there was standard behaviour for this did not succeed.

And in all of the images you've found in the wild, the text is all such that it makes sense for them to be separated by newlines? No words split between comment blocks?

@raygard
Copy link
Contributor Author

raygard commented May 20, 2022

I combed through all the GIFs I have for those with more than one comment block. The result is in https://gist.github.com/raygard/3169ddef212679713d5e7dce81b21b67 . Most are over 20 years old, accumulated from old backups of my kids computers and such. I don't see any that would look right if run together. I realize it's probably a rare situation and maybe not worth the effort to mess with. Especially in Pillow, where (AFAIK) we can't currently even pick up comments after the last image, and that's where most of these came from.

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