Pillow在某些绘制后保存时出现“未知原始模式”错误
我在这里已经提了个问题(https://github.com/python-imaging/Pillow/issues/646),但一直没有得到什么回复。使用Pillow这个库,我在一个很大的白色.gif文件上画了很多线和文字。开始的时候一切都很顺利,但当我画的次数太多时,就出现了问题。这个问题似乎和我在图片上画的内容多少有关。比如说,我可以画更多的小线条,但大线条的数量就有限了。如果画的次数超过了某个值,我就会收到这个错误:
File "draw/card.py", line 13, in save
self.image.save(os.path.join(os.path.dirname(os.path.abspath(__file__)), '%s.gif' % file_name), 'gif')
File ".../local/lib/python2.7/site-packages/PIL/Image.py", line 1564, in save
save_handler(self, fp, filename)
File ".../local/lib/python2.7/site-packages/PIL/GifImagePlugin.py", line 317, in _save
ImageFile._save(imOut, fp, [("gif", (0,0)+im.size, 0, rawmode)])
File ".../local/lib/python2.7/site-packages/PIL/ImageFile.py", line 473, in _save
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
File ".../local/lib/python2.7/site-packages/PIL/Image.py", line 413, in _getencoder
return encoder(mode, *args + extra)
SystemError: unknown raw mode
我把完整的文件路径去掉了,但.../local/lib是在我的虚拟环境里的。
这是一个已知的bug吗?还是我做错了什么,或者我发现了PIL的某个问题?
1 个回答
1
这是Pillow库中的一个错误。根据wiredfool的评论:
为了方便以后通过搜索引擎找到这个问题的人,这确实是一个错误。我在我的电脑上也能重现这个问题。
有一个简单的解决办法——在把图片保存为gif格式之前,先把它转换成'P'模式。