当前位置: 代码迷 >> Ruby/Rails >> PIL中分开通道发生“AttributeError: 'NoneType' object has no attribute 'bands'”
  详细解决方案

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

热度:205   发布时间:2016-04-29 02:16:59.0
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)
  相关解决方案