我正在尝试使用以下代码导出给定图像的调整大小的 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 的子目录。