Keep new IFDs when converting EXIF to bytes

This commit is contained in:
Andrew Murray 2024-12-29 07:43:47 +11:00
parent 1a79d1025c
commit 9368a86397
2 changed files with 7 additions and 0 deletions

View File

@ -793,6 +793,10 @@ class TestImage:
ifd[36864] = b"0220" ifd[36864] = b"0220"
assert exif.get_ifd(0x8769) == {36864: b"0220"} assert exif.get_ifd(0x8769) == {36864: b"0220"}
reloaded_exif = Image.Exif()
reloaded_exif.load(exif.tobytes())
assert reloaded_exif.get_ifd(0x8769) == {36864: b"0220"}
@mark_if_feature_version( @mark_if_feature_version(
pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing" pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
) )

View File

@ -4023,6 +4023,9 @@ class Exif(_ExifBase):
head = self._get_head() head = self._get_head()
ifd = TiffImagePlugin.ImageFileDirectory_v2(ifh=head) ifd = TiffImagePlugin.ImageFileDirectory_v2(ifh=head)
for tag, ifd_dict in self._ifds.items():
if tag not in self:
ifd[tag] = ifd_dict
for tag, value in self.items(): for tag, value in self.items():
if tag in [ if tag in [
ExifTags.IFD.Exif, ExifTags.IFD.Exif,