Saltar para o conteúdo principal
Versão: 20 R9 BETA

OpenAIImage

A classe 'OpenAIImage' representa uma imagem gerada pela API OpenAI. It provides properties for accessing the generated image in different formats and methods for converting this image to different types.

https://platform.openai.com/docs/api-reference/images/object

Propriedades

PropriedadeTipoDescrição
urlTextA URL da imagem gerada, se response_format for url (padrão).
b64_jsonTextThe base64-encoded JSON of the generated image, if response_format is b64_json.
revised_promptDiferente deThe prompt that was used to generate the image, if there was any revision to the prompt.

Funções

asBlob()

asBlob() : 4D.Blob

| Function result| 4D.Blob | Converts the generated image to a blob format based on its URL or base64-encoded JSON. |

Exemplo de uso

var $blob:=$image.asBlob()

asPicture()

asPicture() : Picture

| Function result| Picture | Creates a picture object from the blob converted image. |

Exemplo de uso

var $picture:=$image.asPicture()

saveToDisk()

saveToDisk(file : 4D.File) : Boolean

ParâmetroTipoDescrição
file4D. FileThe file object where the image will be saved.
ResultadoParâmetrosReturns True if the image is successfully saved.

Saves the image to disk, attempting to download it first if it is a URL. Returns False if it could not retrieve the image data.

Exemplo de uso

var $success:=$image.saveToDisk(Folder(fk desktop folder).file("image.png"))