Main Content

imputfile

Display Save Image dialog box

Description

example

[filename,ext,user_canceled] = imputfile displays the Save Image dialog box which you can use to specify the full path and format of a file. Using the dialog box, you can navigate to folders in a file system and select a particular file or specify the name of a new file. imputfile limits the types of files displayed in the dialog box to the image file format selected in the Files of Type menu.

If you click Save, then imputfile returns the full path to the file in filename and the file extension associated with the file format selected from the Files of Type menu in ext. imputfile automatically adds the file name extension (such as .jpg) to the file name.

If you click Cancel or close the Save Image dialog box, then imputfile closes and returns control to MATLAB®, sets user_canceled to True (1), and sets filename and ext to empty character vectors (''). Otherwise, user_canceled is False (0).

Note

The Save Image dialog box is modal; it blocks the MATLAB command line until you click Save or cancel the operation.

Examples

collapse all

Open the Save Image dialog box. This dialog box is modal—control in the command window is suspended until you respond to the Save Image dialog box.

[fn, ext, ucancel] = imputfile

To view only images in Portable Network Graphics format, select the format from the Save as type menu.

Specify a new file name and click Save. imputfile returns the full path of the file name you specified, the file extension, and the Boolean value false, meaning that you did not click Cancel. Note that imputfile automatically adds the file extension of the format you selected to the file name.

fn =

  1×37 char array

    '\\home$\Documents\MATLAB\mytest.png'


ext =

  1×3 char array

    'png'


ucancel =

  logical

   0

Output Arguments

collapse all

Name of file selected, returned as a character array.

File extension of a supported file format, returned as a character array.

Flag indicating if user chose to cancel dialog, returned as true or false.

Data Types: logical

Version History

Introduced in R2007b