Simplify SAMPLEFORMAT when all values match for values other than 1

This commit is contained in:
Andrew Murray 2026-03-30 19:40:04 +11:00
parent 602acd5828
commit 07c180b21e

View File

@ -1473,13 +1473,13 @@ class TiffImageFile(ImageFile.ImageFile):
logger.debug("- size: %s", self.size)
sample_format = self.tag_v2.get(SAMPLEFORMAT, (1,))
if len(sample_format) > 1 and max(sample_format) == min(sample_format) == 1:
if len(sample_format) > 1 and max(sample_format) == min(sample_format):
# SAMPLEFORMAT is properly per band, so an RGB image will
# be (1,1,1). But, we don't support per band pixel types,
# and anything more than one band is a uint8. So, just
# take the first element. Revisit this if adding support
# for more exotic images.
sample_format = (1,)
sample_format = (sample_format[0],)
bps_tuple = self.tag_v2.get(BITSPERSAMPLE, (1,))
extra_tuple = self.tag_v2.get(EXTRASAMPLES, ())