HUGO
Menu
GitHub 90529 stars Mastodon

images.Gamma

Returns an image filter that performs gamma correction on an image.
Syntax
images.Gamma GAMMA
Returns
images.filter

Usage

The images.Gamma function returns an image filter that performs gamma correction on an image. Gamma correction lightens or darkens the midtones of an image without changing pure black or pure white. To change the brightness of every tone by the same amount, use the images.Brightness function instead.

Arguments

GAMMA
(float) The gamma value, typically in the range [0.5, 2]. A value greater than 1 lightens the midtones, a value less than 1 darkens the midtones, and a value of 1 has no effect. A value of 0 or less produces a black image.

Examples

{{ $filter := images.Gamma 1.667 }}

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