ImageFile.Stoner__Image__imagefuncs__save(filename=None, **kargs)

Save the image into the file ‘filename’.


filename (string, bool or None) – Filename to save data as, if this is None then the current filename for the object is used If this is not set, then then a file dialog is used. If filename is False then a file dialog is forced.

Keyword Arguments
  • fmt (string or list) – format to save data as. ‘tif’, ‘png’ or ‘npy’ or a list of them. If not included will guess from filename.

  • forcetype (bool) – integer data will be converted to np.float32 type for saving. if forcetype then preserve and save as int type (will be unsigned).


Metadata will be preserved in .png and .tif format.

fmt can be ‘png’, ‘npy’, ‘tif’, ‘tiff’ or a list of more than one of those. tif is recommended since metadata is lost in .npy format but data is converted to integer format for png so that definition cannot be saved.

Since Stoner.Image is meant to be a general 2d array often with negative and floating point data this poses a problem for saving images. Images are naturally saved as 8 or more bit unsigned integer values representing colour. The only obvious way to save an image and preserve negative data is to save as a float32 tif. This has the advantage over the npy data type which cannot be opened by external programs and will not save metadata.