flatten

The flatten transformation removes the alpha (transparency) channel from an image and replaces transparent areas with a solid background color. Useful for converting PNG with transparency to JPEG or preparing images for systems that don't support transparency.

Serving Content via CDN

The Media API is a CDN-based service that serves transformed images via GET requests. When you request a transformed image URL, the transformation is applied dynamically on the first request and then cached for subsequent requests.

URL Pattern

https://media.vyso.io/flatten:color=COLOR/ASSET_ID.jpg

Examples

Flatten to White Background

curl -i GET https://media.vyso.io/flatten:color=ffffff/ASSET_ID.png

Flatten to Black Background

curl -i GET https://media.vyso.io/flatten:color=000000/ASSET_ID.png

Default Flatten (White)

curl -i GET https://media.vyso.io/flatten/ASSET_ID.png

Flatten to Blue Background

curl -i GET https://media.vyso.io/flatten:color=0066cc/ASSET_ID.png

On the first request, you'll receive a X-Cache: MISS header while the transformation is applied and cached. Subsequent requests will return X-Cache: HIT.

Parameters

colorOPTIONAL

Background color for transparent areas (hex format without #). Accepted values:

  • ffffff - White (default)
  • 000000 - Black
  • cccccc - Light gray
  • 0066cc - Blue
  • Any 6-digit hex color code

Response

The API returns the flattened image without an alpha channel. The response format depends on the format of the asset stored in the Vyso asset cloud.

Content-Type: Determined by the stored asset format (e.g., image/jpeg, image/png)