Skip to content

exif_transpose raises TypeError: object of type 'IFDRational' has no len() #7839

@dkbarn

Description

@dkbarn

What did you do?

Ran ImageOps.exif_transpose on this image: https://i1.sndcdn.com/avatars-000133622422-vmk8sz-original.jpg

What did you expect to happen?

The image to be transposed

What actually happened?

A TypeError exception was raised:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/share/venv-pillow/lib/python3.10/site-packages/PIL/ImageOps.py", line 641, in exif_transpose
    exif_image.info["exif"] = exif.tobytes()
  File "/share/venv-pillow/lib/python3.10/site-packages/PIL/Image.py", line 3798, in tobytes
    return b"Exif\x00\x00" + head + ifd.tobytes(offset)
  File "/share/venv-pillow/lib/python3.10/site-packages/PIL/TiffImagePlugin.py", line 898, in tobytes
    data = ifd.tobytes(offset)
  File "/share/venv-pillow/lib/python3.10/site-packages/PIL/TiffImagePlugin.py", line 898, in tobytes
    data = ifd.tobytes(offset)
  File "/share/venv-pillow/lib/python3.10/site-packages/PIL/TiffImagePlugin.py", line 907, 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.3
  • Python: 3.10.12
  • Pillow: 10.2.0
import io
from PIL import Image, ImageOps
import requests

response = requests.get("https://i1.sndcdn.com/avatars-000133622422-vmk8sz-original.jpg")
image = Image.open(io.BytesIO(response.content))
ImageOps.exif_transpose(image)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAny unexpected behavior, until confirmed feature.TIFF

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions