ResizeImage

Mon 01 January 2018

Syntax

ResizeImage(URL.source_URL, URL.dest_URL, array_of_sizes [, type][, aspect_ratio])

Description

Use the ResizeImage function to create one or more resized copies of the source image. Depending on the image source, ResizeImage supports the following image formats only:

  • Record field: BMP and JPEG.

  • File system folder: BMP, GIF, JPEG, and PNG.

The resized images can be created in file system folder or in a database table. When the destination location is a file system folder, then the name of the resized image is created from the source image file name along with the resize dimensions. For example, if file1.jpg is resized to 40 x 60 pixels, then the resulting file name would be file14060.jpg. If the same file is resized to 10%. the resulting file name would be file110.jpg.

When a database table is specified as the destination location, the PS_PT_IMG_TMPSTORE table is used to temporarily store the images instead of the specified database table. Using the return code of the function invocation as a key value, your application must retrieve the resized images from the PS_PT_IMG_TMPSTORE table.

Column Name

Data Type

Description

PT_IMG_UUID*

Nbr

The return value of the ResizeImage method. All the resized images stored in database for a specific invocation are stored with this identifier.

PT_IMG_FILESEQNO*

Nbr

The sequence number for multiple resizings of the same source image file.

PT_IMG_WIDTH*

Nbr

The image width in pixels.

PT_IMG_HEIGHT*

Nbr

The image height in pixels.

PT_IMG_IMGNAME

Char

The file name of the source image.

PT_IMG_IMGDATA

Long

The image data for the re-sized image.

PSIMAGEVER

Nbr

The image version.

LAST_UPDATE_DTTM

DtTm

The last update timestamp.

OPRID

Char

The operator ID

* Represents a key field. The composite key for a specific resized image would consist of: PT_IMG_UUID + PT_IMG_FILESEQNO + PT_IMG_WIDTH + PT_IMG_HEIGHT + PT_IMG_IMGNAME.

Three image manipulation testing pages provide a sample application that allows an administrator to predefine resize dimensions (Image Size page), predefine groupings of dimensions (Image Group page), and then test the usage of these predefined groups for resizing images (Test Utility page). See for more information.

Parameters

Field or Control

Definition

URL. source_URL

Specifies the location of the source image (or images) as a URL object. The source location can be either a database record or a folder on the application server’s file system containing one or more image files.

When the URL object specifies a database record, you must define three URL properties: to specify the column name from which image data has to be read (), the column name from which the image name has to be taken (), and destination image type ().

  • IMG_DATA_COLUMN: The record field containing the image.

  • IMG_NAME_COLUMN: The record field containing the name of the image.

  • IMG_FILE_FORMAT: The record field specifying the image format. This field serves as a filter, and only images of the specified format are resized.

    Note: If the source record includes more than one row of data, then the IMG_FILE_FORMAT field is ignored.

URL. dest_URL

Specifies the location of the resized image (or images) as a URL object. The destination location can be either a database record or a folder on the application server’s file system.

Important! When the destination location is specified as a database record, the PS_PT_IMG_TMPSTORE table is used to temporarily store the images instead of the specified record. Using the return code of the function invocation as a key value, your application must retrieve the resized images from the PS_PT_IMG_TMPSTORE table. See the “Description” for more information on using the PS_PT_IMG_TMPSTORE table.

array_of_sizes

Specifies resize dimensions as an array of integer. The contents of the array are retrieved in pairs or one-by-one depending on the value of the type parameter. In addition, the array must be terminated with two 0s or one 0, depending on the type parameter.

  • If type is 0 (%Resize_ByDimensions), the values in the array are retrieved in pairs representing the width and height (in pixels) of the resize dimensions. Terminate the array with two 0s. For example, the following array would resize the images to 20x20 pixels, 80x100 pixels, and to a width of 40 pixels maintaining the source images’ aspect ratio:

    &resize_array = CreateArray(20, 20, 80, 100, 40, 0, 0, 0);
  • If type is 1 (%Resize_ByPercentage), the values in the array are retrieved one-by-one representing the percentage to resize the images. Terminate the array with a single 0. For example, the following array would resize the images to 10% and 50%:

    &resize_array = CreateArray(10, 50, 0);

Important! Oracle recommends that you do not resize images to dimensions larger than the original size or to a percentage larger than 100%.

type

Specifies an optional numeric value indicating how to retrieve the values from the array_of_sizes array:

  • %Resize_ByDimensions (0) – The values in the array are retrieved in pairs representing the width and height (in pixels) of the resize dimensions.

  • %Resize_ByPercentage (1) – The values in the array are retrieved one-by-one representing the percentage to resize the images.

aspect_ratio

Specifies an optional Boolean value indicating whether to maintain the aspect ratio of the source image:

  • If aspect_ratio is True and either the height or width is 0, the aspect ratio of the source image is maintained. Otherwise, if both height and width are non-zero values, then aspect_ratio is ignored and the image is resized to the specified aspect ratio.

  • If aspect_ratio is False, then a resize is performed only if both height and width are non-zero values. Otherwise, if either the height or width is 0, no resize is performed.

True is the default value. In addition, the aspect_ratio parameter is ignored when the type parameter is 1 (%Resize_ByPercentage).

Returns

An Integer value representing the unique identifier for the resize invocation. A negative number indicates that the function terminated with an error.