This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

imsave

Save Image Tool

Use the imsave function to create a Save Image tool. The Save Image tool displays an interactive file chooser dialog box (shown below) in which you can specify a path and filename. When you click Save, the Save Image tool writes the target image to a file using the image file format you select in the Files of Type menu. For more information about using the tool, see Tips.

Syntax

imsave
imsave(h)
[filename,user_canceled] = imsave(___)

Description

imsave creates a Save Image tool in a separate figure that is associated with the image in the current figure, called the target image.

imsave(h) creates a Save Image tool associated with the image specified by the handle h.

[filename,user_canceled] = imsave(___) returns the full path to the file selected in filename and indicates whether you canceled the save operation.

Examples

Save Displayed Image

imshow peppers.png
imsave

Input Arguments

collapse all

Handle to a figure, axes, uipanel, or image graphics object, specified as a handle. If h is an axes or figure handle, imsave uses the first image returned by findobj(H,'Type','image').

Output Arguments

collapse all

Full path to file, returned as a character vector. If you cancel the save operation, filename is returned as an empty character array, ''.

User canceled operation, returned as false or true. If you press the Cancel button or close the save window, imsave sets user_canceled to true; otherwise, false.

Tips

  • In contrast to the Save as option in the figure File menu, the Save Image tool saves only the image displayed in the figure. The Save as option in the figure window File menu saves the entire figure window, not just the image.

  • imsave uses imwrite to save the image, using default options.

  • If you specify a filename that already exists, imsave displays a warning message. Select Yes to use the filename or No to return to the dialog to select another filename. If you select Yes, the Save Image tool attempts to overwrite the target file.

  • The Save Image tool is modal; it blocks the MATLAB® command line until you respond.

Introduced in R2007b