mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Add TypeError handling to pass corrupted dpi value in exif
This commit is contained in:
parent
55cec2a0d0
commit
3abe5e884b
BIN
Tests/images/broken_exif_dpi.jpg
Normal file
BIN
Tests/images/broken_exif_dpi.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
|
@ -718,6 +718,15 @@ class TestFileJpeg:
|
|||
# This should return the default, and not raise a ZeroDivisionError
|
||||
assert im.info.get("dpi") == (72, 72)
|
||||
|
||||
def test_dpi_exif_string(self):
|
||||
# Arrange
|
||||
# 0x011A tag in this exif contains string '300300\x02'
|
||||
with Image.open("Tests/images/broken_exif_dpi.jpg") as im:
|
||||
|
||||
# Act / Assert
|
||||
# This should return the default
|
||||
assert im.info.get("dpi") == (72, 72)
|
||||
|
||||
def test_no_dpi_in_exif(self):
|
||||
# Arrange
|
||||
# This is photoshop-200dpi.jpg with resolution removed from EXIF:
|
||||
|
|
|
@ -168,7 +168,7 @@ def APP(self, marker):
|
|||
# 1 dpcm = 2.54 dpi
|
||||
dpi *= 2.54
|
||||
self.info["dpi"] = dpi, dpi
|
||||
except (KeyError, SyntaxError, ValueError, ZeroDivisionError):
|
||||
except (TypeError, KeyError, SyntaxError, ValueError, ZeroDivisionError):
|
||||
# SyntaxError for invalid/unreadable EXIF
|
||||
# KeyError for dpi not included
|
||||
# ZeroDivisionError for invalid dpi rational value
|
||||
|
|
Loading…
Reference in New Issue
Block a user