我正在與images2gif一起工作並且出現此錯誤。有任何想法嗎?UnicodeDecodeError:'ascii'編解碼器無法解碼位置10中的字節0x87:序號不在範圍內(128)
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
哪個Python版本是你嗎? – aIKid
您使用的是哪個版本的images2gif?我看不到在最後一個版本 – PasteBT
該版本沒有內部編碼,似乎對我來說更合理https://github.com/luopio/bag-of-tricks/blob/master/python/images2gif.py;無法猜測爲什麼可以編碼一個字符串; image2gif的代碼看起來不像py3友好,所以我想它是爲py2編寫的 – alko