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, I'm unable to install the PIL module on the server, which is why I have it as a subdirectory of 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
I had this problem because I had both PIL n Pillow installed. So had to uninstall one of them. That solved the problem.
Thanks.
You might want to skip everything and start from loading image and immediately saving it with:
and see what happens. if it works, then add more details, resizing and other stuff.
ah, and don't forget to check write permissions on the folder where you save, because web-server usually runs under different user name.