From a9cb1281f46a98a473274971d0ab3185286f4c73 Mon Sep 17 00:00:00 2001 From: David Schmidt Date: Fri, 24 May 2013 11:55:31 +0200 Subject: [PATCH] fix Python 2 compatibility --- PIL/GifImagePlugin.py | 4 ++-- setup.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py index 1254a396f..5c3e580a4 100644 --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -370,7 +370,7 @@ def getheader(im, palette=None, info=None): for i in usedPaletteColors: paletteBytes += o8(i)*3 else : - paletteBytes = bytes([i//3 for i in range(768)]) + paletteBytes = bytearray([i//3 for i in range(768)]) # TODO improve this, maybe add numpy support # replace the palette color id of all pixel with the new id @@ -386,7 +386,7 @@ def getheader(im, palette=None, info=None): # calculate the palette size for the header import math - colorTableSize = math.ceil(math.log(len(paletteBytes)//3, 2))-1 + colorTableSize = int(math.ceil(math.log(len(paletteBytes)//3, 2)))-1 if colorTableSize < 0: colorTableSize = 0 s.append(o8(colorTableSize + 128)) # size of global color table + global color table flag s.append(o8(0) + o8(0)) # background + reserved/aspect diff --git a/setup.py b/setup.py index dbb83fd48..d0cf95aff 100644 --- a/setup.py +++ b/setup.py @@ -285,10 +285,9 @@ class pil_build_ext(build_ext): elif _find_library_file(self, "tk" + TCL_VERSION): feature.tk = "tk" + TCL_VERSION - if ( - _find_include_file(self, "webp/encode.h") and + if (_find_include_file(self, "webp/encode.h") and _find_include_file(self, "webp/decode.h")): - if _find_library_file(self, "webp"): + if _find_library_file(self, "webp"): # in googles precompiled zip it is call "libwebp" feature.webp = "webp" #