Save Image

Saves an image in a specific format to a directory.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

saveImage --image(Image) --directory(String) [--createrandomfile(Boolean)] --file(String) [--overwrite(Boolean)] --format(SaveImageFormat) (String)=value

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Image image Required Image Image to be saved. You can select an image from a selector, or by selecting assets.
Directory directory Required Text Full directory path where the image is saved.
Create a random name createrandomfile Optional Boolean Creates a random name to the image file.
File name file Only when Create random name is False Text Name for the image file.
Overwrite overwrite Optional Boolean Enable to overwrite an existing file in the selected directory with the same name.
Image format format Required SaveImageFormat Format in which the image is saved. The supported formats are: .bmp, .jpg, and .png.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Path value Text Full path to the saved image file.

Example

The command saves an image of the IBM Robotic Process Automation logo, which was taken from the company's website, on the desktop.

defVar --name pathToSaveImage --type String
defVar --name savedImagePath --type String
defVar --name imageToSave --type Image
// Starts the browser.
webStart --name chrome --type "Chrome" --userprofilepreferences "AutomationOptimized" --downloadpath "C:\\Users\\W00116631\\AppData\\Local\\IBM Robotic Process Automation\\downloads"
// Navigates to the IBM website.
webNavigate --url "www.ibm.com/?lang=en"
// Gets the IBM logo through its XPath.
webGetImage --selector "XPath" --xpath "//*[@id=\"container-9225520bd9\"]/div[1]/dds-masthead-container/dds-masthead/dds-masthead-logo" imageToSave=value
// Closes the browser.
webClose --name chrome
// Gets the location of the Desktop folder.
getSpecialFolder --folder "Desktop" pathToSaveImage=value
// Saves the IBM logo on Desktop with the name IBMlogo.
saveImage --image ${imageToSave} --directory "${pathToSaveImage}" --file IBMlogo --format "Png" savedImagePath=value
// Prints the path where the image was saved.
logMessage --message "${savedImagePath}" --type "Info"