UnicodeDecodeError:'ascii'编解码器无法解码位置10中的字节0x87:序数不在范围内(128)

时间:2013-12-13 22:02:35

标签: python unicode gif

我正在使用images2gif并收到此错误。有什么想法吗?

UnicodeDecodeError: 'ascii' codec can't decode byte 0x87 in position 10: ordinal not in range(128)

测试文件:

from PIL import Image
from images2gif import writeGif

FRAMES = 2
FRAME_DELAY = 0.75
WIDTH, HEIGHT = 600, 600

frames = []
img1 = Image.open('1.jpg')
img2 = Image.open('2.jpg')
frames.append(img1)
frames.append(img2)

writeGif("test.gif", frames, duration=FRAME_DELAY, dither=0)

回溯:

Traceback (most recent call last):
  File "gif.py", line 15, in <module>
    writeGif("topmovie.gif", frames, duration=FRAME_DELAY, dither=0)
  File "/Users/Craig/Documents/github/RTB/images2gif.py", line 575, in writeGif
    gifWriter.writeGifToFile(fp, images, duration, loops, xy, dispose)
  File "/Users/Craig/Documents/github/RTB/images2gif.py", line 435, in writeGifToFile
    fp.write(header.encode('utf-8'))

images2gif第435行:fp.write(header.encode('utf-8'))

更新了追溯:

Traceback (most recent call last):
  File "gif.py", line 16, in <module>
    writeGif("test.gif", frames, duration=FRAME_DELAY, dither=0)
  File "/Users/Craig/Documents/github/RTB/images2gif.py", line 579, in writeGif
    gifWriter.writeGifToFile(fp, images, duration, loops, xy, dispose)
  File "/Users/Craig/Documents/github/RTB/images2gif.py", line 440, in writeGifToFile
    fp.write(globalPalette)
TypeError: must be string or buffer, not None

1 个答案:

答案 0 :(得分:2)

您的更新问题也在此处:Error in images2gif.py with GlobalPalette

它引用了images2gif上的一个问题,其中作者说他们将重写模块以不使用PIL / Pillow,但是很忙:https://code.google.com/p/visvis/issues/detail?id=81

这反过来引用了声称修复此问题的已修补图片2gif:https://github.com/rec/echomesh/blob/master/code/python/external/images2gif.py