相关疑难解决方法(0)

尝试JPEG导出时为TypeError

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

python python-imaging-library

1
推荐指数
1
解决办法
1640
查看次数

标签 统计

python ×1

python-imaging-library ×1