Closed IngeborgGjerde closed 1 week ago
Hi. This is a duplicate of #8471, which has been resolved by #8474.
The next Pillow release is scheduled for January 2.
If you would like to patch your copy of Pillow so that it works in the meantime, you can
from PIL import TiffImagePlugin
# Patch
def _limit_rational(val, max_val):
inv = abs(val) > 1
n_d = TiffImagePlugin.IFDRational(1 / val if inv else val).limit_rational(max_val)
return n_d[::-1] if inv else n_d
TiffImagePlugin._limit_rational = _limit_rational
from PIL import Image
from PIL.ImageOps import exif_transpose
im = Image.open("image.jpg")
width, height = im.size
im = exif_transpose(im)
Hi, many thanks for the quick reply and for providing a workaround!
What did you do?
I was attempting to rotate a picture taken on mobile phone to its upright position.
The image can be downloaded here: https://github.com/user-attachments/assets/b357f0b5-35b3-4b0d-94b1-7f60e3edd075 Running
identify -verbose
on the image shows that it contains orientation databut that it does not contain valid GPS data:
What did you expect to happen?
I expected the image to be rotated :)
What actually happened?
exif_transpose
crashes withThe error is caused by attempting to serialize the gps data.
What are your OS, Python and Pillow versions?