| 1 |
--- |
| 2 |
title: images.Contrast |
| 3 |
description: Returns an image filter that changes the contrast of an image. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
aliases: [] |
| 9 |
returnType: images.filter |
| 10 |
signatures: [images.Contrast PERCENTAGE] |
| 11 |
--- |
| 12 |
|
| 13 |
The percentage must be in the range [-100, 100] where 0 has no effect. A value of `-100` produces a solid grey image, and a value of `100` produces an over-contrasted image. |
| 14 |
|
| 15 |
## Usage |
| 16 |
|
| 17 |
Create the filter: |
| 18 |
|
| 19 |
```go-html-template |
| 20 |
{{ $filter := images.Contrast -20 }} |
| 21 |
``` |
| 22 |
|
| 23 |
{{% include "/_common/functions/images/apply-image-filter.md" %}} |
| 24 |
|
| 25 |
## Example |
| 26 |
|
| 27 |
{{< img |
| 28 |
src="images/examples/zion-national-park.jpg" |
| 29 |
alt="Zion National Park" |
| 30 |
filter="Contrast" |
| 31 |
filterArgs="-20" |
| 32 |
example=true |
| 33 |
>}} |