Fra*_*ter 13 python-imaging-library
我用PIL打开了一张照片,但是当我试图split()分割频道时,我得到了以下错误:
AttributeError: 'NoneType' object has no attribute 'bands'
import Image
img = Image.open('IMG_0007.jpg')
img.split()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/blum/<ipython console> in <module>()
/usr/lib/python2.6/dist-packages/PIL/Image.pyc in split(self)
1495 "Split image into bands"
1496
-> 1497 if self.im.bands == 1:
1498 ims = [self.copy()]
1499 else:
AttributeError: 'NoneType' object has no attribute 'bands'
Run Code Online (Sandbox Code Playgroud)
Fra*_*ter 27
通过谷歌搜索,我在SO上发现了这条评论,声称PIL有时是"懒惰", 并且在打开后"忘记"加载.所以你必须这样做:
import Image
img = Image.open('IMG_0007.jpg')
img.load()
img.split()
Run Code Online (Sandbox Code Playgroud)
请+1也原来的评论!这个人做了真正的工作.
| 归档时间: |
|
| 查看次数: |
16501 次 |
| 最近记录: |