尝试导出JPEG时发生TypeError [英] TypeError when JPEG export is attempted
问题描述
我正在尝试使用以下代码导出给定图像的调整大小的JPEG(下载部分被省略了,因为它可以正常工作):
I'm trying to export resized JPEGs of a given image using the following code (the downloading part is omitted, since that works fine):
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)
但是,在保存新图像(这是回溯)时,出现以下错误:
However, I get the following error when it comes time to save the new image (here's the traceback):
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)
对为什么会发生这种情况有任何想法吗?
Any thoughts on why this is happening?
FWIW,我无法在服务器上安装PIL模块,这就是为什么我将其作为cgi-bin的子目录.
推荐答案
我遇到了同样的问题并解决了.编写此解决方案的原因是,我认为上述答案对于具有相同问题并正在寻找解决方案的其他任何人都不够描述性
I had the same problem and solved it. Writing this solution as I felt that the above answer is not descriptive enough for anyone else having the same problem and looking for solutions
我遇到了这个问题,因为我同时安装了两个PIL n Pillow.因此不得不卸载其中之一.那解决了问题.
I had this problem because I had both PIL n Pillow installed. So had to uninstall one of them. That solved the problem.
谢谢.
这篇关于尝试导出JPEG时发生TypeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!