def save_tiled_raster_images(tiled_img, filename):
 if (tiled_img.ndim == 2):
  ensure_Image()
  img = Image.fromarray(tiled_img, 'L')
 elif (tiled_img.ndim == 3):
  ensure_Image()
  img = Image.fromarray(tiled_img, 'RGBA')
 else:
  raise TypeError('bad ndim', tiled_img)
 img.save(filename)
 return img

def save_tiled_raster_images ( tiled_img , filename ) : if ( tiled_img . ndim == 2 ) : ensure_Image ( ) img = Image . fromarray ( tiled_img , 'L' ) elif ( tiled_img . ndim == 3 ) : ensure_Image ( ) img = Image . fromarray ( tiled_img , 'RGBA' ) else : raise TypeError ( 'bad ndim' , tiled_img ) img . save ( filename ) return img
save a a return value from tile_raster_images to filename .