Imgix APIsRendering APIBlendingBlend Mode

Blend Mode

blend-mode

Blend modes determine how the color, image, or text overlay that’s set with blend will interact with your base image. Use blend-mode[N] to style a specific additional blend layer — styles do not inherit across blend layers.

You may want to experiment with these modes before applying across a wide range of images. The modes can be grouped into general categories based on their effects, as follows.

Accepted Values

CategoryValueEffect
NormalnormalTurns off blending, causing the overlay to be superimposed. This behavior is intended for use with watermarks, similar to the mark parameter.
DarkendarkenCompares the color value of each overlapping pixel from the two layers, and keeps the darker value.
multiplyMultiplies the color values of each overlapping pixel from the two layers, resulting in a darker composite image. Multiplying with black as the blend color will result in black; multiplying with white will leave the image unchanged.
burnDarkens the image based on the overlay image or color.
LightenlightenCompares the color value of each overlapping pixel from the two layers, and keeps the lighter value.
screenThe reverse of multiply — multiplies the inverse of the color values of each overlapping pixel from the two layers, lightening the image.
dodgeBrightens the image based on the overlay image or color.
Contrastoverlay (default)Overlays the blend image or color, while preserving the highlights and shadows. It effectively multiplies or screens, depending on the background color.
softlightLightens each pixel if the overlay is brighter than 50% grey (similar to dodge), and darkens it if the overlay is darker than 50% grey (similar to burn). Effect is like a diffuse spotlight.
hardlightLightens each pixel if the overlay is brighter than 50% grey (similar to screen), and darkens it if the overlay is darker than 50% grey (similar to multiply). Effect is like a harsh spotlight.
InversiondifferenceSubtracts the value of the pixel on the overlay layer from the value of the underlying pixel on the base layer or vice versa, depending on which is brighter.
exclusionSimilar to difference, but with less contrast.
Color ComponentscolorBlends the hue and saturation values of the overlay with the luminance of the base layer.
hueBlends the hue value of the overlay with the luminance and saturation of the base layer.
saturationBlends the saturation value of the overlay with the luminance and hue of the base layer.
luminosityBlends the luminance value of the overlay with the hue and saturation of the base layer.
Knockoutdestination-outRemoves the base image wherever the blend layer covers it, leaving a transparent hole in the shape of the layer.
destination-inKeeps the base image only where the blend layer covers it, removing everything else.

Knockout

destination-out and destination-in are compositing operators rather than color-mixing modes: instead of blending the layer’s color with the base image, they use the layer’s shape to cut the image.

The cutting shape is the layer’s alpha, where it would have been drawn — blend-w, blend-h, blend-fit, blend-align and the positioning parameters all apply as they would for any blend layer. Its colors are never drawn.

A color layer covers the whole image, so it does not cut a shape — it acts on everything by its own alpha. blend=ff000000 (opaque) with destination-out removes the image entirely, while blend=80000000 (half-opaque) fades all of it by half. With destination-in the same colors keep all of the image, or half of it. To cut a specific shape, use an image layer sized and placed with blend-w and blend-align. blend-alpha makes any cut partial in the same way: blend-alpha=50 removes, or keeps, half.

Indexed layers run in order, so a later layer cuts what earlier ones drew, and a cut in one layer does not stop the next from drawing. Watermarks and text are drawn after the blend layers and are never cut by them. Animations are cut on every frame.

Filling the transparency

The hole is filled with bg when you set one, on any format. Without bg:

  • on a format that carries transparency (PNG, WebP, AVIF) the hole is transparent;
  • on JPEG and GIF it is filled with white;
  • with auto=compress and no fm, a JPEG source keeps the hole transparent and is delivered as PNG, as it is for any other transparency the request creates. fm=jpg always fills it.

To cut with a geometric shape instead of a layer, see mask-invert. To cut with text, see txt-blend-mode.

Demo

Color blend modes

blend-mode=normal — Normal
https://assets.imgix.net/examples/bluehat.jpg?w=600&h=400&fit=crop&blend=https%3A%2F%2Fassets.imgix.net%2Fexamples%2Fclouds.jpg&blend-size=inherit&blend-mode=normal
normal

Knockout modes

Each example adds transparency=grid so the checkerboard makes the hole visible. It is not required to use the knockout modes.

The base image, with no blend layer applied.
https://assets.imgix.net/examples/bluehat.jpg?w=300&h=300&fit=crop&fm=png&transparency=grid
no knockout

Try it on your own images

Open the sandbox in your imgix dashboard to build a URL against one of your own sources and watch blend-mode change the output as you type.