From bb5a090f60ed08941e5bdd7077f9a53caec99b57 Mon Sep 17 00:00:00 2001 From: Mikhail Iurkov Date: Wed, 9 Feb 2022 16:16:33 +0300 Subject: [PATCH] Drop excess values in BITSPERSAMPLE --- Tests/images/tiff_wrong_bits_per_sample_2.tiff | Bin 0 -> 1041 bytes Tests/test_file_tiff.py | 14 +++++++++----- src/PIL/TiffImagePlugin.py | 8 ++++++-- 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 Tests/images/tiff_wrong_bits_per_sample_2.tiff diff --git a/Tests/images/tiff_wrong_bits_per_sample_2.tiff b/Tests/images/tiff_wrong_bits_per_sample_2.tiff new file mode 100644 index 0000000000000000000000000000000000000000..d44176ce76ce43f738cf215db0b7974fe3e3ff2a GIT binary patch literal 1041 zcmebD)MDUZW*BkcKPmwFA1DAJAu^BopA1 len(bps_tuple) and len(bps_tuple) == 1: + # while should have more. Or have more values + # than expected. Fix it + bps_actual_count = len(bps_tuple) + if bps_count < bps_actual_count: + bps_tuple = bps_tuple[:bps_count] + elif bps_count > bps_actual_count and bps_actual_count == 1: bps_tuple = bps_tuple * bps_count samplesPerPixel = self.tag_v2.get(