Back to Firebase Js Sdk

ImagenImageFormat class

docs-devsite/ai.imagenimageformat.md

12.12.13.2 KB
Original Source

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

ImagenImageFormat class

Warning: This API is now obsolete.

All Imagen models are deprecated and will shut down as early as June 2026. As a replacement, you can migrate your apps to use Gemini Image models (the "Nano Banana" models)<!-- -->.

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

<b>Signature:</b>

typescript
export declare class ImagenImageFormat 

Properties

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

Methods

MethodModifiersDescription
jpeg(compressionQuality)<code>static</code>Creates an ImagenImageFormat for a JPEG image.
png()<code>static</code>Creates an ImagenImageFormat for a PNG image.

ImagenImageFormat.compressionQuality

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

<b>Signature:</b>

typescript
compressionQuality?: number;

ImagenImageFormat.mimeType

The MIME type.

<b>Signature:</b>

typescript
mimeType: string;

ImagenImageFormat.jpeg()

Creates an ImagenImageFormat for a JPEG image.

<b>Signature:</b>

typescript
static jpeg(compressionQuality?: number): ImagenImageFormat;

Parameters

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

<b>Returns:</b>

ImagenImageFormat

An ImagenImageFormat object for a JPEG image.

ImagenImageFormat.png()

Creates an ImagenImageFormat for a PNG image.

<b>Signature:</b>

typescript
static png(): ImagenImageFormat;

<b>Returns:</b>

ImagenImageFormat

An ImagenImageFormat object for a PNG image.

Example

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