AIC. - Artificial Intelligence Command

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIC. - Artificial Intelligence Command >

AIC. - Artificial Intelligence Command

AIC.EnsureFormatResize

Previous Top Next


MiniRobotLanguage (MRL)

 

AIC.EnsureFormatResize

Automate the process of image format conversion and resizing

 

 

Intention

 

This command is designed to automate the process of image format conversion and resizing.

It is particularly useful in scenarios where consistency in image format and size is required.

Validates the desired image format.

Checks if the file is already in the desired format; if so, returns the original file path.

Attempts to load the image; on failure, sets an error message (AIC.Show Error).

Resizes the image based on ResizeMinFlag, XS, and YS.

If the ResizeMinFlag is set to 1, this changes the resizing behavior to use XS and YS as minimum dimensions and Re-Size the picture with or without Aspect-Ratio (if X or Y is 0, this side is recalculated using the Aspect Ratio).

Generates a unique filename for the converted image.

Saves the image in the new format and frees the loaded image from memory.

 

 

 

Syntax

 

 

AIC.EnsureFormatResize|P1|P2[|P3][|P4][|P5]

 

 

Parameter Explanation

 

P1 - (FilePath in/out) Variable with the path to the source image file. Also contains the destination-image file (if its a Variable). If P1 is not a Variable, the result is placed on TOS.

P2 - (Format) is the desired image format (e.g., 'jpg', 'png', 'bmp').

P3 - (XSize) (optional) is the width to which the image should be resized. If set to 0, the width is auto-calculated.

P4 - (YSize) (optional) is the height to which the image should be resized. If set to 0, the height is auto-calculated.

P5 - (ResizeMinFlag) (optional) is a flag that, if set to 1, changes the resizing behavior to use XS and YS as minimum dimensions.

 

Returns the file-path of a file with the format and dimension as expected in Variable P1.

P1 contains the destination-image file path (if its a Variable). If P1 is not a Variable, the result is placed on TOS.

 

 

Example

 

'***********************************

' IRS.-Sample

'***********************************
' Example SPR-Script to ensure format and resize an image

' FilePath: in $$PAT

' Desired Format: "png"

' Width: 800

' Height: 600

$$PAT=C:\Image.png

AIC.EnsureFormatResize|$$PAT|jpg|800|600

MBX.New Path is: $$PAT

 

' FilePath: in $$PAT

' Desired Format: "JPG"

' Width: 512

' Height: 0 (Keeping Aspect Ratio)

$$PAT=C:\Image.png

' If the file is smaller then 512 Px, it will be resized to 512 Px, keeping the Aspect Ratio

AIC.EnsureFormatResize|$$PAT|jpg|512|0|1

MBX.New Path is: $$PAT

ENR.

 

 

 

 

 

Remarks

 

-

 

 

Limitations:

 

-

 

 

See also: