From 8c003e9b3f9b130f5b1e8d7fcbcf33851b82d6be Mon Sep 17 00:00:00 2001 From: artscoop Date: Thu, 5 Mar 2015 12:17:52 +0100 Subject: [PATCH] And finally ? Error happening in Python 3.x with P images: in original code, palette data was created from a list of bytestrings. Changed to a full bytestring. - `b"".join(list of bytestrings)` works in python 2.7 and 3.x - `b"".join(bytestring)` works in python 2.7 but fails in python 3.x No need to `join` anymore. Works in 3.x --- PIL/BmpImagePlugin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PIL/BmpImagePlugin.py b/PIL/BmpImagePlugin.py index 88f940708..99159d569 100644 --- a/PIL/BmpImagePlugin.py +++ b/PIL/BmpImagePlugin.py @@ -126,7 +126,6 @@ class BmpImageFile(ImageFile.ImageFile): self.mode, raw_mode = BIT2MODE.get(file_info['bits'], (None, None)) if self.mode is None: raise IOError("Unsupported BMP pixel depth (%d)" % file_info['bits']) - #------------------ Process BMP with Bitfields compression (not palette) if file_info['compression'] == self.BITFIELDS: SUPPORTED = {32: [(0xff0000, 0xff00, 0xff, 0x0), (0xff0000, 0xff00, 0xff, 0xff000000), (0x0, 0x0, 0x0, 0x0)], 24: [(0xff0000, 0xff00, 0xff)], 16: [(0xf800, 0x7e0, 0x1f), (0x7c00, 0x3e0, 0x1f)]} @@ -167,7 +166,7 @@ class BmpImageFile(ImageFile.ImageFile): raw_mode = self.mode else: self.mode = "P" - self.palette = ImagePalette.raw("BGRX" if padding == 4 else "BGR", b"".join(palette)) + self.palette = ImagePalette.raw("BGRX" if padding == 4 else "BGR", palette) #------------------------------ Finally set the tile data for the plugin self.info['compression'] = file_info['compression']