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

PIL cannot read JPEG comment #4450

Closed
ganego opened this issue Feb 26, 2020 · 4 comments · Fixed by #4455
Closed

PIL cannot read JPEG comment #4450

ganego opened this issue Feb 26, 2020 · 4 comments · Fixed by #4455
Labels

Comments

@ganego
Copy link

ganego commented Feb 26, 2020

What did you do?

I want PIL to read the JPEG comment (marker: 0xFF 0xFE).

I took an image with an attached JPEG comment - verified with exiftools & IrfanView to exist.

from PIL import Image, JpegImagePlugin
pic = Image.open(<path_to_pic_with_JPEG_comment>)
print(pic.info)

What did you expect to happen?

Show the JPEG comment in the dict.

What actually happened?

{'jfif': 257, 'jfif_version': (1, 1), 'dpi': (96, 96), 'jfif_unit': 1, 'jfif_density': (96, 96), 'exif': b'...'}

What are your OS, Python and Pillow versions?

  • OS: W7x64
  • Python: Python 3.8.1 x64
  • Pillow: Pillow 7.0.0

I cannot attach an image via github ("Something went really wrong, ..."), so here is the file (5.61 KiB) (I downloaded it and verified it's byte-identical to the uploaded one): jpeg-comment-test.jpg

@kkopachev
Copy link
Contributor

It's not exposed under info right now, but could be easily added in https://github.com/python-pillow/Pillow/blob/master/src/PIL/JpegImagePlugin.py#L180

@radarhere radarhere added the JPEG label Feb 27, 2020
@radarhere
Copy link
Member

Yes, for the moment, you can access it through

from PIL import Image
im = Image.open("comment.jpg")
print(im.app["COM"])  # b'JPEG-COMMENT-TEST\x00'

@radarhere
Copy link
Member

I've created PR #4455 to resolve this.

@ganego
Copy link
Author

ganego commented Feb 28, 2020

Thank you both.

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