View Source Image.Color (image v0.33.0)

Functions to manage image color and color conversion.

Link to this section Summary

Types

Reference to an ICC color profile

An rbg color expressed as a list of numbers.

t()

A color can be expressed as a list of numbers or as a CSS color name in atom or string format.

Functions

Returns a mapping from CSS color names to CSS hex values and RGB triplets as a list.

Returns the list of color profiles built into libvips.

Guards whether a given value can be interpreted as a color value.

Guards whether a given profile is one of the inbuilt profiles.

Returns a boolean indicating if the given profile is known and can be used for image operations.

Validates a color returning an [r, g, b] triplet or error.

Link to this section Types

@type icc_profile() :: :none | :cmyk | :srgb | :p3 | Path.t()

Reference to an ICC color profile

  • :none means no profile
  • :cmyk, :srgb and :p3 refer to the built-in color profiles
  • Path.t() means any file system path. If the path is a relative path then is will be loaded from the systems profile directory.
@type rgb_color() :: [number()] | number()

An rbg color expressed as a list of numbers.

The number of list elements and the type varies depending on the image format, colorspace and dimensions.

For a common sRGB image it will be a list of three of four images. If the fourth number is provided it will be considered as an alpha transparency band.

@type t() :: rgb_color() | atom() | String.t()

A color can be expressed as a list of numbers or as a CSS color name in atom or string format.

Link to this section Functions

Returns a mapping from CSS color names to CSS hex values and RGB triplets as a list.

Returns the list of color profiles built into libvips.

Link to this macro

is_color(color)

View Source (macro)

Guards whether a given value can be interpreted as a color value.

Link to this macro

is_inbuilt_profile(profile)

View Source (macro)

Guards whether a given profile is one of the inbuilt profiles.

Link to this function

known_icc_profile?(profile)

View Source

Returns a boolean indicating if the given profile is known and can be used for image operations.

Link to this function

rgba_color!(color, a \\ 255)

View Source

Validates a color returning an [r, g, b] triplet or error.

arguments

Arguments

color which can be specified as a single integer which or a list of integers representing the color. The color can also be supplied as a CSS color name as a string or atom. For example: :misty_rose. See Image.Color.color_map/0 and Image.Color.rgb_color/1.

returns

Returns

  • {:ok, [r, g, b]} or

  • {:error, reason}