python - Unicode解码错误: 'ascii' codec can't decode byte 0x87 in position 10: ordinal not in range(128)

标签 python unicode gif

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

UnicodeDecodeError:“ascii”编解码器无法解码位置 10 中的字节 0x87:序号不在范围内 (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

最佳答案

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

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

这又引用了一个声称可以解决问题的补丁 images2gif:https://github.com/rec/echomesh/blob/master/code/python/external/images2gif.py

关于python - Unicode解码错误: 'ascii' codec can't decode byte 0x87 in position 10: ordinal not in range(128),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20576782/

相关文章:

python - PIL/Pillow 看似任意反转透明度

python - 解释 Python 变量作用域

python - 根据给定的输入集实现 n 叉树

python - Unicode解码错误: 'ascii' codec can't decode byte 0x8b

python - 将 UTF-8 字符串转换为 Python 中的字符串

python - 如何在Python中解码部分转义的unicode字符串(混合unicode和转义的unicode)?

gif图像在html中重复播放

python - 在 Google 应用引擎 (gae) 中针对每个请求验证用户的最佳实践是什么?或者如何避免数据库访问?

python - blobstore 中的非 ascii 文件名 (Google App Engine)

Javascript/JQuery 在 Chrome 和 Firefox 中突然停止工作,但在 Safari 中仍然可以工作