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

解决方法:
这个貌似是属于一个bug
把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)

你可能感兴趣的:(attribute)