code: def save_img(object, handle, **kwargs):
      
  
      if isinstance(object, np.ndarray):
          normalized = _normalize_array(object)
          object = PIL.Image.fromarray(normalized)
  
      if isinstance(object, PIL.Image.Image):
          object.save(handle, **kwargs)  # will infer format from handle's url ext.
      else:
          raise ValueError("Can only save_img for numpy arrays or PIL.Images!")
docs: Save numpy array as image file on CNS.