PIL-量化表数量无效.应该在2到4之间 [英] PIL - Not a valid numbers of quantization tables. Should be between 2 and 4

查看:101
本文介绍了PIL-量化表数量无效.应该在2到4之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的PIL库可以正常工作一段时间,但是现在我到处都可以看到此异常,如何解决此问题?

My PIL library works fine for a while, but now i get this exception everywhere, how to fix this?

f = "/media/bighdd/1.jpg"
from PIL import Image
im = Image.open(f)
im.thumbnail('50x50')
im.save('/media/bighdd/2.jpg')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1437, in save
    save_handler(self, fp, filename)
  File "/usr/local/lib/python2.7/dist-packages/PIL/JpegImagePlugin.py", line 471, in _save
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 494, in _save
    for e, b, o, a in tile:
ValueError: Not a valid numbers of quantization tables. Should be between 2 and 4.

推荐答案

检查是否以这种方式导入了图像:

check that you import Image in this way:

from PIL import Image

在我的代码中出现相同的错误

I had the same error when in my code was

import Image

这个微小的变化使事情发生了

and this tiny change make things roll

这篇关于PIL-量化表数量无效.应该在2到4之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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