imwrite in matlab

imwrite(A,filename,fmt) writes the image in A to filename in the format specified by fmt. A can be either a grayscale image (M-by-N) or a truecolor image (M-by-N-by-3). filename is a string that specifies the name of the output file. Empty image data is not allowed. The possible values for fmt are determined by the MATLAB file format registry.
 

>> %read an Image
>> im = imread('DesertSmall.jpg');
>> % Syntax : imwrite(<image>,<name of new image>,<new image format>)
>> imwrite(im,'newImage.png','png')