All Products
Search
Document Center

PolarDB:AI_ImageFromBase64

Last Updated:Mar 28, 2026

Converts a Base64-encoded string into binary image data (bytea), making image content available as input for AI models running in PolarDB for PostgreSQL.

Syntax

bytea AI_ImageFromBase64(text image)

Parameters

ParameterTypeDescription
imagetextThe Base64-encoded image string. The string must start with data:, followed by the Multipurpose Internet Mail Extensions (MIME) type and the Base64-encoded image data. Example: data:image/jpeg;base64,xxxxx. For MIME type details, see MDN Web Docs: Data URLs.

Return values

Returns the binary image data decoded from the Base64 string, as a bytea value.

Description

Supported image formats: JPEG, PNG, and BMP.

Example

The following example decodes a Base64-encoded JPEG image, which you can then pass as input to a text embedding model in Qwen LLM.

SELECT AI_ImageFromBase64('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD...');