ImagenImageFormat class Stay organized with collections Save and categorize content based on your preferences.
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:
exportdeclareclassImagenImageFormatProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| compressionQuality | number | The level of compression (a number between 0 and 100). | |
| mimeType | string | The MIME type. |
Methods
| Method | Modifiers | Description |
|---|---|---|
| jpeg(compressionQuality) | static | Creates anImagenImageFormat for a JPEG image. |
| png() | static | Creates 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
| Parameter | Type | Description |
|---|---|---|
| compressionQuality | number | The level of compression (a number between 0 and 100). |
Returns:
AnImagenImageFormat object for a JPEG image.
ImagenImageFormat.png()
Creates anImagenImageFormat for a PNG image.
Signature:
staticpng():ImagenImageFormat;Returns:
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.