OOF2: The Manual

Name

OOF.File.Save.Image — Save an Image in a file.

Synopsis

OOF.File.Save.Image(filename, overwrite, image)

Details

  • Parent Menu: OOF.File.Save
  • Callback: function saveImage in module ooflib.image.IO.imagemenu
  • Parameters:

    filename
    Name of the file. The suffix (eg. '.png') determines the file type. Type: A character string.
    overwrite
    Whether or not to overwrite an existing file. Type: Boolean: True or False.
    image
    Type: The path to an existing Image object.

Description

Save the given Image to a file. The file type is determined by the suffix of the given filename. A .png suffix will create a PNG file, and a .pdf suffix will create a PDF file, etc.. File types supported by the Pillow library are acceptable. It is not easy to tell what types can be saved, because it can depend on how the library was built on your computer. OOF2 will tell you if it failed to save an image, though.

In addition to standard image file types, OOF2 can save images as Numpy data files by using the suffixes .npy (uncompressed) or .npz (compressed). These file types have the advantage of storing full precision data. If you have modified an image in OOF2, it may contain pixel values that cannot be represented exactly in an image file — many of the image file types are written with fewer bits per pixel than OOF2 uses internally.[19] In this case, saving and reloading an image will not reproduce the original data. If exact reproduction is important, use the .npy or .npz suffixes.

If you are saving a grayscale image, some of the file types will economically store just a single channel, but some will store RGB or RGBA data instead, creating a file three or four times larger than necessary (before compression).

Also, note Pillow can write more formats that it can read.

Some common and/or useful file formats are:

  • NPY and NPZ.  These are Numpy data files that store the full precision of the image data. NPZ files are compressed. They can be read by OOF2, but possibly not by other image apps.

  • PNG.  Grayscale PNG files, as saved by OOF2, contain a single channel of 16 bit values. Color PNG files contain three channels of 8 bit values.

  • PDF.  PDF files can be saved by OOF2, but can't be loaded.

  • GIF.  This is a static GIF file, not an animated one.[20] It contains 4 channels of 8 bit data for both color and grayscale images.

  • TIF and TIFF.  TIFF files seem to contain full precision data, and are loadable by OOF2, but can't always be read by other programs.



[19] OOF2 stores image data as floats.

[20] What kids call "gifs" these days are properly called "animated gifs". The original "gif" was an image compression format for static images.