From 4f6f5f918247ec9e474c7e443ae0c1995c4e2861 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 30 Dec 2015 09:37:24 +1100 Subject: [PATCH 1/3] Changed int conversion in ImagePalette to ord for Python 2 --- PIL/ImagePalette.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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") From 3c2e37482412f35a126fbd22fea41c4aac371a63 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 30 Dec 2015 09:37:50 +1100 Subject: [PATCH 2/3] Added test --- Tests/images/chi.gif | Bin 0 -> 85539 bytes Tests/test_imagedraw.py | 7 +++++++ 2 files changed, 7 insertions(+) create mode 100644 Tests/images/chi.gif diff --git a/Tests/images/chi.gif b/Tests/images/chi.gif new file mode 100644 index 0000000000000000000000000000000000000000..d217f8b5eaf60d4d9a43e079dee8420408c86795 GIT binary patch literal 85539 zcmeF3Ra6}8vZlLn*B~LdySux)2X_w;+-YdsT>>GvySq!{Zoz{F2pTL9GW>h*BQtAe zt+_aJ);W9V>+Z|0_o=6LG}Se=G_VQrq;F_!U}R!wY-(g;W^8J1VrF4#ZfRy=X>Ms{VP$P;ZDVC)Yi(m^ZEJ61=U{99 z!Op?a{)3Z)qw@!+kB%Q*on72My1Ki#dAPcJx_NlHdwP3#`FMK!dinTy`}+I%1^D_0 z`UQae1A_v*qWD3dePEATlOHNHsNy|u0&rHksl>R9zBkOZ!c23sk zFWEV{pTFeg2EiWmnC@rrntEeh3>JY4~ zt|;yls;a3h=@PE4tt#ynsjaWBYpAJjtZQhhZ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pxW{W$zj?+>;!zZSa1GwyOKOZX z?@{EF5Z>%plJvk9GM<2k3emYT{e%JT)YI&oda3;V-c8=ODc92Tu7Pf8fLo)(cf!X*68WMv%18xotgR zF{cG_C#Kstr1rA{lT(8BYEFB9kHZj-^<8G;W#<5@`@!pigEun|j?^5y({u38dW;5e z4B!~RF@R$L#{iB290NE8a17uWz_C9L%>a%89IIp{95QAeY5uO(XY2Ft2aY%{t_jG- zS%w{LxzfnUVyqlIs=9U{q@24i>{#oKHtVMNdxOW?qUr=^3M>~LcfF`iyw1k25=1E7{D=rV*tkhjsYA4 zI0kSG;26L$fMeiyY@m#}tTlGvaMKXLF(4}fSrN#JKvo2@B9IkU|UF>pHuZpXmw7`Pn+w`1UT>>m|9!0i~g9Rso=NO^#i2S|B< zlm|$8fRqPFd4QA$NO^#i2S|B~5P*wzGMNn1*Wkpa{1Z71~ zRs>~5-SjgkD}u5jC@X@{JqX={&^-vWJMq=0$CBria=HbvLcWb!3;E*fd(_sUSHPZ literal 0 HcmV?d00001 diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 947e35971..b86ae7768 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -52,6 +52,13 @@ class TestImageDraw(PillowTestCase): self.assertRaises(Exception, lambda: draw.setink(0)) self.assertRaises(Exception, lambda: draw.setfill(0)) + def test_valueerror(self): + im = Image.open("Tests/images/chi.gif") + + draw = ImageDraw.Draw(im) + draw.line(((0, 0)), fill=(0, 0, 0)) + del draw + def test_mode_mismatch(self): im = hopper("RGB").copy() From c6489e6fb73819845effb18bfb961e2ca97b859e Mon Sep 17 00:00:00 2001 From: wiredfool Date: Thu, 9 Jun 2016 22:32:16 +0100 Subject: [PATCH 3/3] bytearray as preferred palette storage --- PIL/ImagePalette.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PIL/ImagePalette.py b/PIL/ImagePalette.py index a7f4c1b5f..1affc5394 100644 --- a/PIL/ImagePalette.py +++ b/PIL/ImagePalette.py @@ -38,7 +38,7 @@ class ImagePalette(object): def __init__(self, mode="RGB", palette=None, size=0): self.mode = mode self.rawmode = None # if set, palette contains raw data - self.palette = palette or list(range(256))*len(self.mode) + self.palette = palette or bytearray(range(256))*len(self.mode) self.colors = {} self.dirty = None if ((size == 0 and len(self.mode)*256 != len(self.palette)) or @@ -98,8 +98,7 @@ class ImagePalette(object): except KeyError: # allocate new color slot if isinstance(self.palette, bytes): - self.palette = [(ord(x) if str is bytes else int(x)) - for x in self.palette] + self.palette = bytearray(self.palette) index = len(self.colors) if index >= 256: raise ValueError("cannot allocate more than 256 colors")