Resizes image data to specified dimensions before AI inference to reduce processing overhead.
Syntax
bytea AI_ResizeImage (bytea image, integer width, integer height)Parameters
| Parameter | Type | Description |
|---|---|---|
image | bytea | The image data in binary format. |
width | integer | The target width in pixels. If the value is <= 0, the width scales proportionally to maintain the original aspect ratio. |
height | integer | The target height in pixels. If the value is <= 0, the height scales proportionally to maintain the original aspect ratio. |
Return value
Returns the resized image in binary format (bytea). The output image is in the same format as the input.
Usage notes
Supported image formats: JPEG, PNG, and BMP.
JPEG output is compressed at 75% quality.
During AI inference, the model pre-processes the input image. During embedding calculation, the image is resized to smaller dimensions for consistent processing. Call
AI_ResizeImageto resize images before running AI inference—this reduces the amount of data the model processes and improves overall performance.
Examples
Resize an image to 256×256 pixels:
SELECT ai_resizeimage(data, 256, 256) FROM ai_image_test WHERE id = 1;Resize the width to 256 pixels and scale the height proportionally:
SELECT ai_resizeimage(data, 256, 0) FROM ai_image_test WHERE id = 1;