- Media API
- Transformations
- Adjust
- flatten
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.jpgExamples
Flatten to White Background
curl -i GET https://media.vyso.io/flatten:color=ffffff/ASSET_ID.pngFlatten to Black Background
curl -i GET https://media.vyso.io/flatten:color=000000/ASSET_ID.pngDefault Flatten (White)
curl -i GET https://media.vyso.io/flatten/ASSET_ID.pngFlatten to Blue Background
curl -i GET https://media.vyso.io/flatten:color=0066cc/ASSET_ID.pngOn 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
colorOPTIONALBackground color for transparent areas (hex format without #). Accepted values:
ffffff- White (default)000000- Blackcccccc- Light gray0066cc- 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)