【发布时间】:2010-10-14 20:32:39
【问题描述】:
我正在使用 PIL
im = Image.open(teh_file)
if im:
colors = im.resize( (1,1), Image.ANTIALIAS).getpixel((0,0)) # simple way to get average color
red = colors[0] # and so on, some operations on color data
问题是,在一些(很少,特别是不知道为什么那些确切的,简单的 jpeg)上,我在“colors[0]”行上得到“不可订阅的对象”。试过了:
if colors:
变得真实并继续。
if len(colors):
给出'len() of unsized object'
- 我应该申请什么条件才不会获得此异常?
- 问题的原因是什么?
【问题讨论】:
标签: python image image-processing colors python-imaging-library