尝试JPEG导出时为TypeError

teh*_*ckz 1 python python-imaging-library

我正在尝试使用以下代码导出给定图像的已调整大小的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)
Run Code Online (Sandbox Code Playgroud)

但是,当需要保存新图像时,我收到以下错误(这里是回溯):

  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)
Run Code Online (Sandbox Code Playgroud)

有关为什么会发生这种情况的任何想法?

FWIW,我无法在服务器上安装PIL模块,这就是为什么我把它作为cgi-bin的子目录.

Sar*_*tra 7

我有同样的问题并解决了它.写这个解决方案,因为我觉得上面的答案对于其他有相同问题并寻找解决方案的人来说不够具有描述性

我有这个问题,因为我安装了PIL n Pillow.所以不得不卸载其中一个.这解决了这个问题.

谢谢.