HUGO
Menu
GitHub 90529 stars Mastodon

images.Colorize

Returns an image filter that produces a colorized version of an image.
Syntax
images.Colorize HUE SATURATION STRENGTH
Returns
images.filter

Usage

The images.Colorize function returns an image filter that produces a colorized version of an image. The filter replaces the hue and saturation of each pixel with the given values, and keeps the lightness of each pixel. To shift the existing colors of an image instead of replacing them, use the images.Hue function.

Arguments

HUE
(float) The color to apply, expressed as an angle on the color wheel, in degrees. For example, 0 is red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, and 300 is magenta. Values outside the range [0, 360] wrap around the color wheel, so -120 and 600 are the same as 240.
SATURATION
(float) The intensity of the color to apply, as a percentage in the range [0, 100]. A value of 0 produces a grayscale image, and a value of 100 applies the most intense version of the color.
STRENGTH
(float) The strength of the effect, as a percentage in the range [0, 100].

Examples

{{ $filter := images.Colorize 180 50 20 }}

Applying the filter with the images.Filter function:

{{ with resources.Get "images/original.jpg" }}
  {{ with . | images.Filter $filter }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ end }}
{{ end }}

Applying the filter with the Filter method on a Resource object:

{{ with resources.Get "images/original.jpg" }}
  {{ with .Filter $filter }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ end }}
{{ end }}

This is the original image:

Zion National Park

This is the processed image:

Zion National Park