代码改变世界

PIL中分离通道发生“AttributeError: 'NoneType' object has no attribute 'bands'”

2015-11-05 10:30  sophia194910  阅读(304)  评论(0编辑  收藏  举报

解决方法: 把Image.py中的1500行左右的split函数改成如下即可:

def split(self):
    "Split image into bands"
    self.load()    //增加这一行
    if self.im.bands == 1:
        ims = [self.copy()]
    else:
        ims = []
        #self.load()   //注释这一行
        for i in range(self.im.bands):
            ims.append(self._new(self.im.getband(i)))
    return tuple(ims)