我想導出使用下面的代碼給定的圖像大小的JPEG文件(省略下載的部分,因爲這工作正常):類型錯誤時,JPEG出口試圖
basewidth = 400 # user-defined variable
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
theitemishere = "/home/myusername/public_html/resizer/" + filename
img.save(theitemishere + extension, extension_caps)
但是,我得到的以下錯誤,當談到時間來保存新的圖像(這裏的回溯):
File "/home/myusername/public_html/cgi-bin/PIL/Image.py", line 1467, in save
save_handler(self, fp, filename)
File "/home/myusername/public_html/cgi-bin/PIL/JpegImagePlugin.py", line 557, in _save
ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
File "/home/myusername/public_html/cgi-bin/PIL/ImageFile.py", line 466, in _save
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
File "/home/myusername/public_html/cgi-bin/PIL/Image.py", line 395, in _getencoder
return encoder(mode, *args + extra)
TypeError: function takes at most 11 arguments (13 given)
上爲什麼發生這種情況有什麼想法?
FWIW,我無法在服務器上安裝PIL模塊,這就是爲什麼我把它作爲cgi-bin的子目錄。
完整的源代碼可以在[this gist]中找到(https://gist.github.com/anonymous/5234052) – tehsockz 2013-03-24 23:27:57