ImagenImageFormat class

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 ofImagenModelParams.

Signature:

exportdeclareclassImagenImageFormat

Properties

PropertyModifiersTypeDescription
compressionQualitynumberThe level of compression (a number between 0 and 100).
mimeTypestringThe MIME type.

Methods

MethodModifiersDescription
jpeg(compressionQuality)staticCreates anImagenImageFormat for a JPEG image.
png()staticCreates anImagenImageFormat for a PNG image.

ImagenImageFormat.compressionQuality

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

Signature:

compressionQuality?:number;

ImagenImageFormat.mimeType

The MIME type.

Signature:

mimeType:string;

ImagenImageFormat.jpeg()

Creates anImagenImageFormat for a JPEG image.

Signature:

staticjpeg(compressionQuality?:number):ImagenImageFormat;

Parameters

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

Returns:

ImagenImageFormat

AnImagenImageFormat object for a JPEG image.

ImagenImageFormat.png()

Creates anImagenImageFormat for a PNG image.

Signature:

staticpng():ImagenImageFormat;

Returns:

ImagenImageFormat

AnImagenImageFormat object for a PNG image.

Example

constimagenModelParams={// ... other ImagenModelParamsimageFormat:ImagenImageFormat.jpeg(75)// JPEG with a compression level of 75.}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-09 UTC.