Add Luminance to Color

To sort an image's colors from darkest to lightest, you can then do:

```handlebars
{{ {{ $colorsByLuminance := sort $image.Colors "Luminance" }}
```

This uses the formula defined here: https://www.w3.org/TR/WCAG21/#dfn-relative-luminance

Fixes #10450
This commit is contained in:
Bjørn Erik Pedersen
2024-04-15 10:09:25 +02:00
parent 74e9129568
commit e197c7b29d
12 changed files with 204 additions and 39 deletions

View File

@@ -63,7 +63,7 @@ type ImageResourceOps interface {
// Colors returns a slice of the most dominant colors in an image
// using a simple histogram method.
Colors() ([]string, error)
Colors() ([]Color, error)
// For internal use.
DecodeImage() (image.Image, error)