# imwrite

Writes an image, whose pixel data comes from a matrix, m, with functions defined in the omlimgtoolbox.

## Syntax

imwrite(m, file)

imwrite(m, file, ext)

imwrite(m, ..., 'Alpha', alpha, 'Quality', quality, 'WriteMode', mode, ...)

## Inputs

m
2D or ND matrices with the pixel data for the image to write.
Type: matrix
file
Name of the image file to write.
Type: string
ext (optional)
Specifies the extension to use for the image file to be written. If this option is used, file should be the base name with no extension specified.
Type: string
alpha (optional)
Name-value pair to specify the alpha channel of the image. If specified, the dimensions of alpha should be the same as m. If not specified, the image is considered to be opaque.
Type: matrix
quality (optional)
Name-value pair to specify the quality of the image written. Valid values are integers between 0 to 100, with 100 being of the highest quality. If not specified, the default value is 99.
Type: integer
mode (optional)
Name-value pair which specifies whether data needs to be appended or overwritten on an existing image file, file. Valid values are 'overwrite' and 'append', the default option being 'overwrite'.
Type: string

## Examples

Write an image with the default options:
addlibrary('omlimgtoolbox')
imwrite(m, 'oml_img_1640.jpg');
addtoolbox('omlimgtoolbox')
imwrite(m, 'oml_img_1640', 'png', 'Alpha', alpha, 'Quality', 85, 'WriteMode', 'overwrite');