ImagenImageFormat class

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Defines the image format for images generated by Imagen.

Use this class to specify the desired format (JPEG or PNG) and compression quality for images generated by Imagen. This is typically included as part of ImagenModelParams.

Signature:

export declare class ImagenImageFormat 

Properties

Property Modifiers Type Description
compressionQuality number (Public Preview) The level of compression (a number between 0 and 100).
mimeType string (Public Preview) The MIME type.

Methods

Method Modifiers Description
jpeg(compressionQuality) static (Public Preview) Creates an ImagenImageFormat for a JPEG image.
png() static (Public Preview) Creates an ImagenImageFormat for a PNG image.

ImagenImageFormat.compressionQuality

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

The level of compression (a number between 0 and 100).

Signature:

compressionQuality?: number;

ImagenImageFormat.mimeType

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

The MIME type.

Signature:

mimeType: string;

ImagenImageFormat.jpeg()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Creates an ImagenImageFormat for a JPEG image.

Signature:

static jpeg(compressionQuality?: number): ImagenImageFormat;

Parameters

Parameter Type Description
compressionQuality number The level of compression (a number between 0 and 100).

Returns:

ImagenImageFormat

An ImagenImageFormat object for a JPEG image.

ImagenImageFormat.png()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Creates an ImagenImageFormat for a PNG image.

Signature:

static png(): ImagenImageFormat;

Returns:

ImagenImageFormat

An ImagenImageFormat object for a PNG image.

Example

const imagenModelParams = {
  // ... other ImagenModelParams
  imageFormat: ImagenImageFormat.jpeg(75) // JPEG with a compression level of 75.
}