Merge pull request #4677 from radarhere/exif_start

Corrected reading EXIF metadata without prefix
This commit is contained in:
Hugo van Kemenade 2020-06-07 22:06:02 +03:00 committed by GitHub
commit b2f00d7c59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -30,6 +30,15 @@ def test_read_exif_metadata():
assert exif_data == expected_exif assert exif_data == expected_exif
def test_read_exif_metadata_without_prefix():
with Image.open("Tests/images/flower2.webp") as im:
# Assert prefix is not present
assert im.info["exif"][:6] != b"Exif\x00\x00"
exif = im.getexif()
assert exif[305] == "Adobe Photoshop CS6 (Macintosh)"
def test_write_exif_metadata(): def test_write_exif_metadata():
file_path = "Tests/images/flower.jpg" file_path = "Tests/images/flower.jpg"
test_buffer = BytesIO() test_buffer = BytesIO()

View File

@ -3289,7 +3289,9 @@ class Exif(MutableMapping):
if not data: if not data:
return return
self.fp = io.BytesIO(data[6:]) if data.startswith(b"Exif\x00\x00"):
data = data[6:]
self.fp = io.BytesIO(data)
self.head = self.fp.read(8) self.head = self.fp.read(8)
# process dictionary # process dictionary
from . import TiffImagePlugin from . import TiffImagePlugin