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

Error reading metadata when using Image.getexif().tobytes() #7185

Closed
lyaoworkaccount opened this issue May 25, 2023 · 2 comments
Closed

Error reading metadata when using Image.getexif().tobytes() #7185

lyaoworkaccount opened this issue May 25, 2023 · 2 comments
Labels

Comments

@lyaoworkaccount
Copy link

lyaoworkaccount commented May 25, 2023

What did you do?

Using Pillow to read the exif metadata of a jpg image

What did you expect to happen?

Expected the metadata to converted into bytes

What actually happened?

Issue in the tobytes() function reading the metadata

python3.9/site-packages/PIL/TiffImagePlugin.py", line 895, in tobytes
    "<table: %d bytes>" % len(data) if len(data) >= 16 else str(values)
TypeError: object of type 'IFDRational' has no len()

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 22.04.2
  • Python: 3.9.9
  • Pillow: 9.4.0
from io import BytesIO
from pathlib import Path
from PIL import Image

with Path(__file__).with_name("sample.jpg").open("rb") as fp:
    image = Image.open(BytesIO(fp.read())) 
    image.getexif().tobytes()

a whited out 1x1 pixel image with the metadata that has this problem is attached below

sample

@radarhere
Copy link
Member

Hi. This has already been resolved by #6890. If you upgrade to Pillow 9.5.0, your problem should be fixed.

@radarhere radarhere changed the title Error reading metadata when using Image.getxif().tobytes() Error reading metadata when using Image.getexif().tobytes() May 25, 2023
@lyaoworkaccount
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants