mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-04 14:26:17 +03:00
Merge pull request #1 from radarhere/exif-writing-fixes
Corrected short and long range checks
This commit is contained in:
commit
47513c5430
|
@ -274,6 +274,18 @@ class TestFileTiffMetadata(PillowTestCase):
|
|||
self.assertEqual(numerator, reloaded.tag_v2[37380].numerator)
|
||||
self.assertEqual(denominator, reloaded.tag_v2[37380].denominator)
|
||||
|
||||
def test_ifd_signed_long(self):
|
||||
im = hopper()
|
||||
info = TiffImagePlugin.ImageFileDirectory_v2()
|
||||
|
||||
info[37000] = -60000
|
||||
|
||||
out = self.tempfile("temp.tiff")
|
||||
im.save(out, tiffinfo=info, compression="raw")
|
||||
|
||||
reloaded = Image.open(out)
|
||||
self.assertEqual(reloaded.tag_v2[37000], -60000)
|
||||
|
||||
def test_expty_values(self):
|
||||
data = io.BytesIO(
|
||||
b"II*\x00\x08\x00\x00\x00\x03\x00\x1a\x01\x05\x00\x00\x00\x00\x00"
|
||||
|
|
|
@ -575,12 +575,10 @@ class ImageFileDirectory_v2(MutableMapping):
|
|||
else TiffTags.SIGNED_RATIONAL
|
||||
)
|
||||
elif all(isinstance(v, int) for v in values):
|
||||
if all(v < 2 ** 16 for v in values):
|
||||
self.tagtype[tag] = (
|
||||
TiffTags.SHORT
|
||||
if all(v >= 0 for v in values)
|
||||
else TiffTags.SIGNED_SHORT
|
||||
)
|
||||
if all(0 <= v < 2 ** 16 for v in values):
|
||||
self.tagtype[tag] = TiffTags.SHORT
|
||||
elif all(-2 ** 15 < v < 2 ** 15 for v in values):
|
||||
self.tagtype[tag] = TiffTags.SIGNED_SHORT
|
||||
else:
|
||||
self.tagtype[tag] = (
|
||||
TiffTags.LONG
|
||||
|
|
Loading…
Reference in New Issue
Block a user