code: def putalpha(self, alpha):
          
          alpha = np.ma.array(alpha)
          if(not (alpha.shape[0] == 0 and
                  self.shape[0] == 0) and
             alpha.shape != self.shape):
              raise ValueError("Alpha channel shape should match image shape")
  
          if not self.mode.endswith("A"):
              self.convert(self.mode + "A")
          if not self.is_empty():
              self.channels[-1] = alpha
docs: Adds an *alpha* channel to the current image, or replaces it with
          *alpha* if it already exists.