fix Python 2 compatibility

This commit is contained in:
David Schmidt 2013-05-24 11:55:31 +02:00
parent 12cea19280
commit a9cb1281f4
2 changed files with 4 additions and 5 deletions

View File

@ -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

View File

@ -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"
#