How to serve images with tranparent background from Dynamic Media
This article explains if Dynamic Media can serve images with a transparent background.
Description description
Environment
Dynamic Media Classic
Issue/Symptoms
Even when uploading an image in png format with a transparent background, serving that image from Dynamic Media results in a white background. How can we maintain transparency?
Resolution resolution
The default output format for images isjpeg
which does not support transparency. Even with SmartImaging turned on, where the image gets converted into webp
or avif
, sincejpeg
does not support transparency, the webp
or avif
it is converted into won鈥檛 have transparency either.
The way to make sure that the response image has transparency is to explicitly request an image format with an alpha channel, e.g. by adding fmt=png-alpha
, fmt=png8-alpha
, or fmt=gif-alpha
. That will make sure the transparency is maintained, also when the image is converted into webp
or avif
using SmartImaging.