Infery.ai
← All tools

Flatten alpha

Image

image.flatten

in: imageout: image

Remove alpha channel; fill transparent areas with background colour.

Pricing

Price
0.125 cr / request

Prices in credits (1 credit = $0.01).

Flatten Alpha

Remove the alpha (transparency) channel from an image, filling transparent areas with a solid background colour.

When to use

  • Prepare for JPEG output — JPEG does not support transparency; flatten before converting format.
  • Consistent rendering — ensure transparent PNGs display a predictable background in all viewers.
  • Reduce file size — images without alpha compress more efficiently in JPEG/WebP lossy mode.

Inputs & outputs

Input modalityImage file (URL)
Output modalityImage file (GCS URL)
Max input size50 MB
Supported formatsPNG, WebP, TIFF, AVIF (any format with alpha)

Parameters

ParamRequiredDescription
backgroundnoHex colour to use for transparent areas (default #ffffff). Accepts 6-digit (#rrggbb) or 8-digit (#rrggbbaa) hex.

Examples

Flatten to white background

{
  "type": "image.flatten",
  "input": { "image_url": "gs://infery-prod-media/assets/logo-transparent.png" },
  "params": { "background": "#ffffff" }
}

Flatten to dark background for dark-mode export

{
  "type": "image.flatten",
  "input": { "image_url": "gs://infery-prod-media/icons/icon.png" },
  "params": { "background": "#1a1a2e" }
}

Pricing

Billed per megapixel of output image. See pricing dashboard for current rates.

Related capabilities

  • image.convert_format — convert to JPEG after flattening (JPEG requires no alpha)
  • image.add_alpha_channel — inverse operation: add alpha to an opaque image
  • image.pipeline — chain flatten with other ops in a single execution

Examples

White background

{
  "background": "#ffffff"
}