mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +03:00
Merge pull request #1414 from wiredfool/pr1360
Catch TypeError in _getexif
This commit is contained in:
commit
991829b75a
|
@ -422,8 +422,11 @@ def _getexif(self):
|
||||||
exif[key] = _fixup(value)
|
exif[key] = _fixup(value)
|
||||||
# get exif extension
|
# get exif extension
|
||||||
try:
|
try:
|
||||||
|
# exif field 0x8769 is an offset pointer to the location
|
||||||
|
# of the nested embedded exif ifd.
|
||||||
|
# It should be a long, but may be corrupted.
|
||||||
file.seek(exif[0x8769])
|
file.seek(exif[0x8769])
|
||||||
except KeyError:
|
except (KeyError, TypeError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
info = TiffImagePlugin.ImageFileDirectory(head)
|
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||||
|
@ -432,8 +435,11 @@ def _getexif(self):
|
||||||
exif[key] = _fixup(value)
|
exif[key] = _fixup(value)
|
||||||
# get gpsinfo extension
|
# get gpsinfo extension
|
||||||
try:
|
try:
|
||||||
file.seek(exif[0x8825])
|
# exif field 0x8825 is an offset pointer to the location
|
||||||
except KeyError:
|
# of the nested embedded gps exif ifd.
|
||||||
|
# It should be a long, but may be corrupted.
|
||||||
|
file.seek(exif[0x8825])
|
||||||
|
except (KeyError, TypeError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
info = TiffImagePlugin.ImageFileDirectory(head)
|
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||||
|
|
BIN
Tests/images/exif_gps_typeerror.jpg
Normal file
BIN
Tests/images/exif_gps_typeerror.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
BIN
Tests/images/exif_typeerror.jpg
Normal file
BIN
Tests/images/exif_typeerror.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
|
@ -166,6 +166,17 @@ class TestFileJpeg(PillowTestCase):
|
||||||
im = hopper()
|
im = hopper()
|
||||||
im.save(f, 'JPEG', quality=90, exif=b"1"*65532)
|
im.save(f, 'JPEG', quality=90, exif=b"1"*65532)
|
||||||
|
|
||||||
|
def test_exif_typeerror(self):
|
||||||
|
im = Image.open('Tests/images/exif_typeerror.jpg')
|
||||||
|
# Should not raise a TypeError
|
||||||
|
im._getexif()
|
||||||
|
|
||||||
|
def test_exif_gps_typeerror(self):
|
||||||
|
im = Image.open('Tests/images/exif_gps_typeerror.jpg')
|
||||||
|
|
||||||
|
# Should not raise a TypeError
|
||||||
|
im._getexif()
|
||||||
|
|
||||||
def test_progressive_compat(self):
|
def test_progressive_compat(self):
|
||||||
im1 = self.roundtrip(hopper())
|
im1 = self.roundtrip(hopper())
|
||||||
im2 = self.roundtrip(hopper(), progressive=1)
|
im2 = self.roundtrip(hopper(), progressive=1)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user