b = image_name.save(image_filenameʃ, quality := qualityʅ);
The
Image.save function writes the contents of the
Image object to a file specified by the string expression
image_filename. The image can be saved in three formats, with the format determined by the file extension: JPEG (.jpg/.jpeg), PNG (.png), and BMP (.bmp). Although GIF files can be loaded by
Image.load, images cannot be saved to the GIF format.
When saving to JPEG format, the quality can be specified using a
named argument. The numeric expression
quality must be a value from 0 to 100, with 100 being the best quality. If not specified, a value of 95 is used. The file size will be bigger the higher the quality number. This value is ignored if not saving to JPEG format.
The function returns a logical value of 1 (
true) if the image was saved, 0 (
false) if there was an error writing the file, and
default if the image object does not contain an image.
Image roof_photo;
if roof_photo.takePhoto("Take a photo of the household's roof.") then
// in case the device's camera takes photos with an unnecessarily
// large resolution, resample the image to a more reasonable size
roof_photo.resample(maxWidth := 1600, maxHeight := 1200);
// save the image using the household key...
string base_filename = Path.concat(application, "Roof Photos", key(HH_DICT));
// ...with 90 quality to prevent the JPEG from being too large
roof_photo.save(base_filename + ".jpg", quality := 90);
endif;