images.ColorBalance
- Syntax
- images.ColorBalance RED GREEN BLUE
- Returns
- images.filter
Usage
The images.ColorBalance function returns an image filter that changes the color balance of an image by adjusting the red, green, and blue channels. Each pixel’s color is a combination of these three channels. Increasing a channel adds more of that color to the image, and decreasing a channel removes it. For example, images.ColorBalance 0 0 20 makes the image slightly bluer, and images.ColorBalance -100 0 0 removes all red from the image.
Each argument is a percentage change in the range [-100, 500], where -100 removes the channel, 0 has no effect, and 100 doubles the channel. Values outside this range are treated as -100 or 500.
Arguments
RED- (
float) The percentage change in the red channel. GREEN- (
float) The percentage change in the green channel. BLUE- (
float) The percentage change in the blue channel.
Examples
{{ $filter := images.ColorBalance -10 10 50 }}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:

This is the processed image:

