python save保存图片系统提示错误请帮忙分析python源码,savepython,很基本的操作,比如imp
很基本的操作,比如import Imageim = Image.open('male.png')im.save('test.png')
就能出错,报错信息是这样的:
Traceback (most recent call last):
File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1439, in save
save_handler(self, fp, filename)
File "/usr/local/lib/python2.7/dist-packages/PIL/PngImagePlugin.py", line 572, in _save
ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)])
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 481, in _save
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 399, in _getencoder
return apply(encoder, (mode,) + args + extra)
但是im.show()
是可以看到图片的。
搜了好久都没搜到类似的问题...
刚提问就搜到答案了!
参考:http://stackoverflow.com/questions/17451711/typeerror-when-resizing-an-image-with-pil-in-python/17451810#17451810
改变一下导入方式就能解决这个问题了from PIL import Image
感谢万能的栈爆网!XD
编橙之家文章,