Mismatch on count of items, sampleformat is troublesome UNDONE--approach?

This commit is contained in:
wiredfool 2016-12-14 07:42:58 -08:00
parent d79b1d4a04
commit 5c9de81f9f

View File

@ -549,7 +549,11 @@ class ImageFileDirectory_v2(collections.MutableMapping):
if info.length == 1: if info.length == 1:
if legacy_api and self.tagtype[tag] in [5, 10]: if legacy_api and self.tagtype[tag] in [5, 10]:
values = values, values = values,
dest[tag], = values try:
dest[tag], = values
except ValueError:
# there's a mismatch between the spec and the item from the file.
dest[tag] = values
else: else:
dest[tag] = values dest[tag] = values
@ -1145,6 +1149,8 @@ class TiffImageFile(ImageFile.ImageFile):
print("- size:", self.size) print("- size:", self.size)
sampleFormat = self.tag_v2.get(SAMPLEFORMAT, (1,)) sampleFormat = self.tag_v2.get(SAMPLEFORMAT, (1,))
if not isinstance(sampleFormat, tuple):
sampleFormat = (sampleFormat,)
if (len(sampleFormat) > 1 if (len(sampleFormat) > 1
and max(sampleFormat) == min(sampleFormat) == 1): and max(sampleFormat) == min(sampleFormat) == 1):
# SAMPLEFORMAT is properly per band, so an RGB image will # SAMPLEFORMAT is properly per band, so an RGB image will