mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Save interop IFD when converting Exif to bytes
This commit is contained in:
parent
b25bc40009
commit
e763f8f2be
|
@ -752,9 +752,14 @@ class TestImage:
|
|||
4098: 1704,
|
||||
}
|
||||
|
||||
reloaded_exif = Image.Exif()
|
||||
reloaded_exif.load(exif.tobytes())
|
||||
assert reloaded_exif.get_ifd(0xA005) == exif.get_ifd(0xA005)
|
||||
|
||||
def test_exif_ifd(self):
|
||||
im = Image.open("Tests/images/flower.jpg")
|
||||
exif = im.getexif()
|
||||
with Image.open("Tests/images/flower.jpg") as im:
|
||||
exif = im.getexif()
|
||||
del exif.get_ifd(0x8769)[0xA005]
|
||||
|
||||
reloaded_exif = Image.Exif()
|
||||
reloaded_exif.load(exif.tobytes())
|
||||
|
|
|
@ -3373,6 +3373,13 @@ class Exif(MutableMapping):
|
|||
for tag, value in self.items():
|
||||
if tag in [0x8769, 0x8225] and not isinstance(value, dict):
|
||||
value = self.get_ifd(tag)
|
||||
if (
|
||||
tag == 0x8769
|
||||
and 0xA005 in value
|
||||
and not isinstance(value[0xA005], dict)
|
||||
):
|
||||
value = value.copy()
|
||||
value[0xA005] = self.get_ifd(0xA005)
|
||||
ifd[tag] = value
|
||||
return b"Exif\x00\x00" + head + ifd.tobytes(offset)
|
||||
|
||||
|
|
|
@ -184,6 +184,7 @@ TAGS_V2 = {
|
|||
34665: ("ExifIFD", LONG, 1),
|
||||
34675: ("ICCProfile", UNDEFINED, 1),
|
||||
34853: ("GPSInfoIFD", LONG, 1),
|
||||
40965: ("InteroperabilityIFD", LONG, 1),
|
||||
# MPInfo
|
||||
45056: ("MPFVersion", UNDEFINED, 1),
|
||||
45057: ("NumberOfImages", LONG, 1),
|
||||
|
|
Loading…
Reference in New Issue
Block a user