mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Changed to ImageFileDirectory_v2
This commit is contained in:
parent
ba58ae752c
commit
ccac9e1a3a
|
@ -219,7 +219,7 @@ class TestFileJpeg:
|
|||
gps_index = 34853
|
||||
expected_exif_gps = {
|
||||
0: b"\x00\x00\x00\x01",
|
||||
2: (4294967295, 1),
|
||||
2: 4294967295,
|
||||
5: b"\x01",
|
||||
30: 65535,
|
||||
29: "1999:99:99 99:99:99",
|
||||
|
@ -241,7 +241,7 @@ class TestFileJpeg:
|
|||
36867: "2099:09:29 10:10:10",
|
||||
34853: {
|
||||
0: b"\x00\x00\x00\x01",
|
||||
2: (4294967295, 1),
|
||||
2: 4294967295,
|
||||
5: b"\x01",
|
||||
30: 65535,
|
||||
29: "1999:99:99 99:99:99",
|
||||
|
@ -253,11 +253,11 @@ class TestFileJpeg:
|
|||
271: "Make",
|
||||
272: "XXX-XXX",
|
||||
305: "PIL",
|
||||
42034: ((1, 1), (1, 1), (1, 1), (1, 1)),
|
||||
42034: (1, 1, 1, 1),
|
||||
42035: "LensMake",
|
||||
34856: b"\xaa\xaa\xaa\xaa\xaa\xaa",
|
||||
282: (4294967295, 1),
|
||||
33434: (4294967295, 1),
|
||||
282: 4294967295,
|
||||
33434: 4294967295,
|
||||
}
|
||||
|
||||
with Image.open("Tests/images/exif_gps.jpg") as im:
|
||||
|
@ -647,6 +647,19 @@ class TestFileJpeg:
|
|||
# OSError for unidentified image.
|
||||
assert im.info.get("dpi") == (72, 72)
|
||||
|
||||
def test_exif_x_resolution(self, tmp_path):
|
||||
with Image.open("Tests/images/flower.jpg") as im:
|
||||
exif = im.getexif()
|
||||
assert exif[282] == 180
|
||||
|
||||
out = str(tmp_path / "out.jpg")
|
||||
with pytest.warns(None) as record:
|
||||
im.save(out, exif=exif)
|
||||
assert len(record) == 0
|
||||
|
||||
with Image.open(out) as reloaded:
|
||||
assert reloaded.getexif()[282] == 180
|
||||
|
||||
def test_invalid_exif_x_resolution(self):
|
||||
# When no x or y resolution is defined in EXIF
|
||||
with Image.open("Tests/images/invalid-exif-without-x-resolution.jpg") as im:
|
||||
|
|
|
@ -3248,7 +3248,7 @@ class Exif(MutableMapping):
|
|||
|
||||
def _fixup(self, value):
|
||||
try:
|
||||
if len(value) == 1 and not isinstance(value, dict):
|
||||
if len(value) == 1 and isinstance(value, tuple):
|
||||
return value[0]
|
||||
except Exception:
|
||||
pass
|
||||
|
@ -3269,7 +3269,7 @@ class Exif(MutableMapping):
|
|||
else:
|
||||
from . import TiffImagePlugin
|
||||
|
||||
info = TiffImagePlugin.ImageFileDirectory_v1(self.head)
|
||||
info = TiffImagePlugin.ImageFileDirectory_v2(self.head)
|
||||
info.load(self.fp)
|
||||
return self._fixup_dict(info)
|
||||
|
||||
|
@ -3294,7 +3294,7 @@ class Exif(MutableMapping):
|
|||
# process dictionary
|
||||
from . import TiffImagePlugin
|
||||
|
||||
self._info = TiffImagePlugin.ImageFileDirectory_v1(self.head)
|
||||
self._info = TiffImagePlugin.ImageFileDirectory_v2(self.head)
|
||||
self.endian = self._info._endian
|
||||
self.fp.seek(self._info.next)
|
||||
self._info.load(self.fp)
|
||||
|
|
Loading…
Reference in New Issue
Block a user