image

fetchImages

Description

Fetches images from a CAS table and sends them to the client for display or further processing. This action allows retrieval of binary image data along with associated metadata variables. It supports pagination (from/to), sorting of results, and random selection via a seed.

Settings
ParameterDescription
fetchImagesVarsSpecifies the variables to copy from the input table to the output result. Useful for retrieving metadata like paths or labels alongside the image.
fromSpecifies the ordinal position of the first row to return. Default is 0.
imageSpecifies the name of the column that contains image binaries. Default is '_image_'.
imagesSpecifies the list of parameters that describe the input image table, such as column mappings for id, label, path, etc.
seedSpecifies a seed for writing images randomly. Default is 0.
sortBySpecifies one or more variables and their sort order (ASCENDING or DESCENDING) to determine the order of the results.
tableSpecifies the input table that contains image data. Can include caslib, where clause, and computed variables.
toSpecifies the ordinal position of the last image row to return. Default is 20.
Data Preparation View data prep sheet
Load Image Data

Before fetching, images must be loaded into a CAS table. This step loads images from a directory.

Copied!
1 
2PROC CAS;
3image.loadImages / path="/path/to/images" casout={name="myImages", replace=true};
4 
5RUN;
6 

Examples

Fetches the default number of images (up to 20) from the 'myImages' table.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3image.fetchImages / TABLE="myImages";
4 
5RUN;
6 
Result :
Returns the binary image data and standard metadata for the first 20 images in the table.

Fetches a specific range of images (10 to 30), sorted by the file path, and includes specific metadata variables.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3image.fetchImages / TABLE="myImages" from=10 to=30 sortBy={{name="_path_", order="ASCENDING"}} fetchImagesVars={"_path_", "_type_"};
4 
5RUN;
6 
Result :
Returns images from row 10 to 30, sorted alphabetically by their path, including only the image binary, path, and type variables in the result.

FAQ

What is the purpose of the fetchImages action?
Which parameter specifies the input table containing image data?
How can I specify which variables to copy to the output table?
How do I define the range of rows to return?
What is the default column name for image binaries?
How can I sort the results returned by the action?
What does the `seed` parameter do?
What information can be specified within the `images` parameter?