PIL(图像)ValueError:不是有效数量的量化表。应介于1和4之间 [英] PIL (Image) ValueError: Not a valid number of quantization tables. Should be between 1 and 4

查看:209
本文介绍了PIL(图像)ValueError:不是有效数量的量化表。应介于1和4之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在图片上绘制一个矩形并将其另存为新文件。我正在做的是:

I want to draw a rectangle on a picture and save it as a new file. what I'm doing is below:

from PIL import Image
from PIL import ImageChops
from PIL import ImageDraw

im = Image.open('the animal picture.jpg')
draw = ImageDraw.Draw(im)
draw.rectangle((69, 17, 418, 107))
im = im.convert('RGB')
im.save('new.jpg')

它给出了一条错误消息:

It gives an error message:

Traceback (most recent call last):
  File "C:\Python27\draw_re.py", line 9, in <module>
    im.save('new.jpg')
  File "C:\Python27\lib\PIL\Image.py", line 1439, in save
    save_handler(self, fp, filename)
  File "C:\Python27\lib\PIL\JpegImagePlugin.py", line 471, in _save
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
  File "C:\Python27\lib\PIL\ImageFile.py", line 494, in _save
    for e, b, o, a in tile:
ValueError: Not a valid number of quantization tables. Should be between 1 and 4.

看起来像PIL - 不是有效数量的量化表。应介于2和4之间,但提示并未解决问题。它使批处理变得不可能。

It looks like the problem in PIL - Not a valid numbers of quantization tables. Should be between 2 and 4, but the tip doesn't solve the problem. It makes batch processing impossible.

推荐答案

我把它解决了。由我正在使用的Image和PIL库引起的问题。

I worked it out. The problem caused by the Image and PIL libraries I am using.

我卸载并删除了之前安装的所有PIL和Image库(以前存在混淆和原始安装困难)所以我有文件库的交叉文件和文件夹。

I uninstalled and removed all previous installed PIL and Image libraries (there were confusion before and difficulties in original installations) so I have cross files and folders for the libraries.

我通过pip进行了卸载,并在控制面板\所有控制面板项目\程序和功能中进行了卸载Windows也是如此。还手动删除残留文件夹和文件。

I did the uninstallations through pip, and "Control Panel\All Control Panel Items\Programs and Features" in Windows as well. Also have manually removed the residues folders and files.

枕头是应该使用的枕头。我从 https://pypi.python.org/pypi/Pillow下载了MS Windows安装程序/2.6.1 并安装它。运行脚本,它运行正常。

Pillow is the one shall be used. I downloaded a MS Windows installer from https://pypi.python.org/pypi/Pillow/2.6.1 and installed it. Run the script and it's working fine.

这篇关于PIL(图像)ValueError:不是有效数量的量化表。应介于1和4之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆