From a4028112e340b20909746daca0f8cabb09cbf28f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 21 Sep 2022 16:24:54 +0200 Subject: resources/images: Add $image.Colors Which returns the most dominant colors of an image using a simple histogram method. Fixes #10307 --- .../content/en/content-management/image-processing/index.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docs/content') diff --git a/docs/content/en/content-management/image-processing/index.md b/docs/content/en/content-management/image-processing/index.md index f2748f5db..d99ea7846 100644 --- a/docs/content/en/content-management/image-processing/index.md +++ b/docs/content/en/content-management/image-processing/index.md @@ -163,6 +163,19 @@ Sometimes it can be useful to create the filter chain once and then reuse it. {{ $image2 := $image2.Filter $filters }} ``` +### Colors + +{{< new-in "0.104.0" >}} + +`.Colors` returns a slice of hex string with the dominant colors in the image using a simple histogram method. + +```go-html-template +{{ $colors := $image.Colors }} +``` + +This method is fast, but if you also scale down your images, it would be good for performance to extract the colors from the scaled down image. + + ### Exif Provides an [Exif] object containing image metadata. -- cgit v1.2.3