SAVEIMAGE

Purpose:

Saves an image to  BMP, GIF, JPEG, PNG, TIF and other image file formats.

Syntax:

SAVEIMAGE("filename", "format", series, overwrite)

"filename"

-

A string, the name of the target image file.

"format"

-

Optional. A string, the destination image file format. Defaults to the file extension. Supports the following extensions:

"bmp"

:

Windows bitmap format

"dng", "adng"

:

Adobe Digital Negative format

"dds"

:

DirectDraw Surface

"gif"

:

Graphics Interchange Format

"heif"

:

High Efficiency Image File 

"ico"

:

Windows Icon format

"jpg, "jpeg"

:

Joint Photographic Experts Group format

"png"

:

Portable Network Graphics format

"raw", "nef"

:

Nikon Electric Format

"tif", "tiff"

:

Tagged Image File Format

"webp"

:

Google raster file format

"wmp"

:

Windows Media Player format

series

-

Optional. A series or window, the image to save. Defaults to the current window.

overwrite

-

Optional. An integer, the overwrite mode:

0:

prompt before overwriting file (default)

1:

overwrite file if it exists without prompting

2:

cancel if file exists

 

Returns:

An integer, 1 if successful, < 0 if failure.

Example:

W1: readimage(gethome + "data\mandrill.bmp")

saveimage(getmiscpath(1, 1) + "mandrill.png", w1, 1);

W2: readimage(getmiscpath(1, 1) + "mandrill.png")

 

W1 reads and displays the bitmap image file "mandrill.bmp".

 

SAVEIMAGE saves the image as a PNG file as determined by the "png" file extension. The existing file, if any, is overwritten.

 

W2 loads the PNG file. The image is the same as W1.

 

Example:

W3: spline2(randn(10), 10);setplottype(3);turbo

saveimage(getmiscpath(1, 1) + "density.png", w3, 1);

W4: readimage(getmiscpath(1, 1) + "density.png")

 

W3 creates a density plot by 2D cubic spline interpolation of a 10x10 random matrix, The resulting image is 91x91 and shaded using the TURBO color scheme.

 

SAVEIMAGE saves the density plot as a JPG file. The existing file if any, is overwritten.

 

W4 loads the JPG file. The image is the same as W3.

Remarks:

SAVEIMAGE saves an image from a window or series to a variety of image file formats.

 

By default, the type of saved image is determined by the filename extension. Current supported extensions include BMP, GIF, JPG, PNG and TIF.

 

See READIMAGE to load an image file.

See Also:

GETRGB

IMAGE24

READIMAGE

RGBIMAGE

SETASPECT

WRITEBMP