image pil 图像保存_使用PIL保存图像
我正在嘗試使用PIL保存我從頭開始創建的圖像
newImg1 = PIL.Image.new('RGB', (512,512))
pixels1 = newImg1.load()
...
for i in range (0,511):
for j in range (0,511):
...
pixels1[i, 511-j]=(0,0,0)
...
newImg1.PIL.save("img1.png")
我收到以下錯誤:
Traceback(最近一次調用最后一次):文件“”,第1行,文件“C:\ Python27 \ lib \ site-packages \ spyderlib \ widgets \ externalshell \ sitecustomize.py”,第523行,在runfile execfile中(文件名,命名空間)文件“C:\ Python27 \ Lib \ site-packages \ xy \ pyimgmake.py”,第125行,在newImg1.PIL.save(“img1.png”)文件“C:\ Python27 \ lib \ site-packages \ PIL \ Image.py“,第512行,getattr引發AttributeError(name)AttributeError:PIL
我需要幫助解釋此錯誤以及如何正確保存圖像為“img1.png”(我很好將圖像保存到默認保存點) .
更新:
from PIL import Image as pimg
...
newImg1 = pimg.new('RGB', (512,512))
...
newImg1.save("img1.png")
我收到以下錯誤:
... newImg1.save(“img1.png”)文件“C:\ Python27 \ lib \ site-packages \ PIL \ Image.py”,第1439行,保存save_handler(self,fp,filename)文件“C :\ Python27 \ lib \ site-packages \ PIL \ PngImagePlugin.py“,第572行,_save ImageFile._save(im,_idat(fp,chunk),[(”zip“,(0,0)im.size, 0,rawmode)])文件“C:\ Python27 \ lib \ site-packages \ PIL \ ImageFile.py”,第481行,在_save中e = Image._getencoder(im.mode,e,a,im.encoderconfig)文件“C:\ Python27 \ lib \ site-packages \ PIL \ Image.py”,第399行,在_getencoder中返回apply(編碼器,(模式,)args extra)TypeError:需要一個整數
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的image pil 图像保存_使用PIL保存图像的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle修改成olap模式,的Ora
- 下一篇: c语言 把字符串转换为变量名_如何将抓取