diff --git a/PIL/ImagePalette.py b/PIL/ImagePalette.py index fdc5a46ca..a7f4c1b5f 100644 --- a/PIL/ImagePalette.py +++ b/PIL/ImagePalette.py @@ -98,7 +98,8 @@ class ImagePalette(object): except KeyError: # allocate new color slot if isinstance(self.palette, bytes): - self.palette = [int(x) for x in self.palette] + self.palette = [(ord(x) if str is bytes else int(x)) + for x in self.palette] index = len(self.colors) if index >= 256: raise ValueError("cannot allocate more than 256 colors")