
See imformats for more information about this registry. The MATLAB file format registry determines which file formats are supported. This table summarizes the types of images that imwrite can write. For the lists of parameters available for each format, see Format-Specific Parameters. Parameter settings can currently be made for HDF, JPEG, PBM, PGM, PNG, PPM, and TIFF files.

For example, if you are writing a JPEG file, you can set the quality of the JPEG compression. Imwrite(.,Param1,Val1,Param2,Val2.) specifies parameters that control various characteristics of the output file. The extension must be one of the legal values for fmt. Imwrite(.,filename) writes the image to filename, inferring the format to use from the filename's extension. Note that most image file formats do not support colormaps with more than 256 entries. The map parameter must be a valid MATLAB colormap. If X is of class double, the imwrite function offsets the values in the array before writing using uint8(X-1). If X is of class uint8 or uint16, imwrite writes the actual values in the array to the file. Imwrite(X,map,filename, fmt ) writes the indexed image in X and its associated colormap map to filename in the format specified by fmt.


To view a summary of these formats, see Supported Formats. The possible values for fmt are determined by the MATLAB file format registry. filename is a string that specifies the name of the output file. A can be either a grayscale image (M-by-N) or a truecolor image (M-by-N-by-3). Imwrite(A,filename, fmt ) writes the image in A to filename in the format specified by fmt. Imwrite (MATLAB Functions) MATLAB Function Reference
