Resizes binary image data to specified dimensions.
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 as bytea (binary format).
Usage notes
Supported formats: JPEG, PNG, and BMP. The output format matches the input format.
For JPEG images, the output is compressed at 75% quality.
During AI inference, models pre-process input images by resizing them to smaller dimensions for consistent processing. To reduce data volume and improve inference performance, resize images with this function before submitting them to an AI inference workflow.
Examples
Resize to fixed dimensions
Resize the image to 256 × 256 pixels:
SELECT ai_resizeimage(data, 256, 256) FROM ai_image_test WHERE id = 1;Resize width only
Resize the width to 256 pixels and scale the height proportionally:
SELECT ai_resizeimage(data, 256, 0) FROM ai_image_test WHERE id = 1;