mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-23 05:34:45 +03:00
Fix EXIF serialization issue due to mismatch between legacy and new mode
This commit is contained in:
parent
29fee8fc43
commit
a896a4fdff
BIN
Tests/images/exif_transpose_rational_mismatch.jpg
Normal file
BIN
Tests/images/exif_transpose_rational_mismatch.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 MiB |
|
@ -307,3 +307,10 @@ def test_exif_transpose():
|
|||
"Tests/images/hopper_orientation_" + str(i) + ext
|
||||
) as orientation_im:
|
||||
check(orientation_im)
|
||||
|
||||
|
||||
def test_exif_transpose_metadata_error():
|
||||
with Image.open("Tests/images/exif_transpose_rational_mismatch.jpg") as img:
|
||||
transposed = ImageOps.exif_transpose(img)
|
||||
parsed_exif = transposed.getexif()
|
||||
assert parsed_exif[318] == [(313, 1000), (329, 1000)]
|
||||
|
|
|
@ -258,8 +258,9 @@ def _accept(prefix):
|
|||
|
||||
|
||||
def _limit_rational(val, max_val):
|
||||
inv = abs(val) > 1
|
||||
n_d = IFDRational(1 / val if inv else val).limit_rational(max_val)
|
||||
ifd_val = IFDRational(val[0], val[1]) if isinstance(val, tuple) else val
|
||||
inv = abs(ifd_val) > 1
|
||||
n_d = IFDRational(1 / ifd_val if inv else ifd_val).limit_rational(max_val)
|
||||
return n_d[::-1] if inv else n_d
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user