Resizes binary image data to specified dimensions.
Syntax
bytea AI_ResizeImage (bytea image, integer width, integer height)Parameters
Parameter | Description |
image | The image data in binary format. |
width | The width to which the image is resized. If the value is <= 0, the width is scaled proportionally to maintain the original aspect ratio. |
height | The height to which the image is resized. If the value is <= 0, the height is scaled proportionally to maintain the original aspect ratio. |
Return values
Returns the resized image in binary format.
Description
This function supports the following image formats: JPEG, PNG, and BMP. The resized image maintains the same format as the original image. For JPEG images, the resized image is compressed at 75% quality.
During AI inference, a model first pre-processes the input image. During embedding calculation, the image is resized to smaller dimensions to ensure consistent and uniform processing. To improve performance and reduce the amount of processed data, we recommend that you use this function to resize the image data before performing AI inference.
Examples
Resize the image data to a size of 256 pixels in width and 256 pixels in height.
SELECT ai_resizeimage(data, 256, 256) FROM ai_image_test WHERE id = 1;Resize the image width to 256 pixels. The height is scaled proportionally to maintain the original aspect ratio.
SELECT ai_resizeimage(data, 256, 0) FROM ai_image_test WHERE id = 1;