colors

package
v0.0.0-...-c8acfb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package colors provides types and functions for color classification.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

This section is empty.

Variables

View Source
var ColorExamples = map[Color]string{
	Black:   "#212121",
	Grey:    "#9E9E9E",
	Brown:   "#A1887F",
	Gold:    "#D4AF37",
	White:   "#F5F5F5",
	Purple:  "#AB47BC",
	Blue:    "#2196F3",
	Cyan:    "#00BCD4",
	Teal:    "#009688",
	Green:   "#66BB6A",
	Lime:    "#CDDC39",
	Yellow:  "#FDD835",
	Magenta: "#FF00FF",
	Orange:  "#FFA726",
	Red:     "#EF5350",
	Pink:    "#EC407A",
}
View Source
var ColorMap = map[color.RGBA]Color{}/* 269 elements not displayed */
View Source
var Names = map[Color]string{
	Black:   "black",
	Grey:    "grey",
	Brown:   "brown",
	Gold:    "gold",
	White:   "white",
	Purple:  "purple",
	Blue:    "blue",
	Cyan:    "cyan",
	Teal:    "teal",
	Green:   "green",
	Lime:    "lime",
	Yellow:  "yellow",
	Magenta: "magenta",
	Orange:  "orange",
	Red:     "red",
	Pink:    "pink",
}
View Source
var Weights = map[Color]uint16{
	Grey:    1,
	Black:   2,
	Brown:   2,
	White:   2,
	Blue:    3,
	Green:   3,
	Purple:  4,
	Gold:    4,
	Cyan:    4,
	Teal:    4,
	Orange:  4,
	Red:     4,
	Pink:    4,
	Lime:    5,
	Yellow:  5,
	Magenta: 5,
}

Functions

func ToSRGB

func ToSRGB(img image.Image, profile Profile) image.Image

ToSRGB converts an image to sRGB colors.

Types

type Chroma

type Chroma int16

Chroma represents colorfulness.

func (Chroma) Hex

func (c Chroma) Hex() string

Hex returns the colourfulness in percent has hex string.

func (Chroma) Int

func (c Chroma) Int() int

Int returns the colourfulness in percent as integer.

func (Chroma) Percent

func (c Chroma) Percent() int16

Percent returns the colourfulness in percent.

func (Chroma) Uint

func (c Chroma) Uint() uint

Uint returns the colourfulness in percent as unsigned integer.

type Color

type Color int16
const (
	Black Color = iota
	Grey
	Brown
	Gold
	White
	Purple
	Blue
	Cyan
	Teal
	Green
	Lime
	Yellow
	Magenta
	Orange
	Red
	Pink
)

func Colorful

func Colorful(actualColor colorful.Color) (result Color)

Colorful finds the Color most similar to the specified colorful.Color.

func (Color) Hex

func (c Color) Hex() string

func (Color) ID

func (c Color) ID() int16

func (Color) Name

func (c Color) Name() string

type ColorPerception

type ColorPerception struct {
	Colors    Colors
	MainColor Color
	Luminance LightMap
	Chroma    Chroma
}

ColorPerception provides information on how an image looks in terms of color and light.

type Colors

type Colors []Color

func (Colors) Hex

func (c Colors) Hex() (result string)

func (Colors) List

func (c Colors) List() []map[string]string

type LightMap

type LightMap []Luminance

func (LightMap) Diff

func (m LightMap) Diff() (result int)

Diff returns an integer that can be used to find similar images.

func (LightMap) Hex

func (m LightMap) Hex() (result string)

Hex returns all luminance value as a hex encoded string.

type Luminance

type Luminance int16

func (Luminance) Hex

func (l Luminance) Hex() string

type Profile

type Profile string
const (
	Default          Profile = ""
	ProfileDisplayP3 Profile = "Display P3"
)

Supported color profiles.

func (Profile) Equal

func (p Profile) Equal(s string) bool

Equal compares the color profile name case-insensitively.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL