HUGO
Menu
GitHub 90529 stars Mastodon

images.Contrast

Returns an image filter that changes the contrast of an image.
Syntax
images.Contrast AMOUNT
Returns
images.filter

Usage

The images.Contrast function returns an image filter that changes the contrast of an image. To change the contrast while preserving highlight and shadow detail, use the images.Sigmoid function instead.

Arguments

AMOUNT
(float) The percentage change in contrast, in the range [-100, 100]. A value of 0 has no effect, a value of -100 produces a solid gray image, and a value of 100 produces an over-contrasted image.

Examples

{{ $filter := images.Contrast -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