b = image_name.load(image_file_path);
b = image_name.load(valueset_name, value);
The
Image.load function reads an image from a file and stores its contents in the
Image object. In the first version of the function, the string expression
image_file_path specifies the location of the image on the disk.
The second version simplifies loading
value set images. It is equivalent to calling:
image_name.load(getimage(valueset_name, value));
The following types of images are supported:
- JPEG (.jpg/.jpeg).
- PNG (.png).
- WebP (.webp).
- BMP (.bmp).
- ICO (.ico). ICO files can only be loaded on Windows but can be saved on all platforms.
- GIF (.gif). GIF files can only be loaded and cannot be saved.
The function returns a logical value of 1 (
true) if the image was loaded and 0 (
false) if the image could not be loaded.
// create thumbnails for every image in the Photos directory,
// placing the thumbnails in the Thumbnails directory
List string image_listing;
dirlist(image_listing, "Photos", "*.jpg;*.png");
do numeric counter = 1 while counter <= image_listing.length()
Image thumbnail_image;
if thumbnail_image.load(image_listing(counter)) then
// create a thumbnail at 25% of the original image size
thumbnail_image.resample(thumbnail_image.width() / 4, thumbnail_image.height() / 4);
// prefix the thumbnail filename with the text "tn"
string thumbnail_filename = Path.concat("Thumbnails", "tn" + Path.getFileName(image_listing(counter)));
thumbnail_image.save(thumbnail_filename);
endif;
enddo;