View Source Image.Color (image v0.44.0)
Functions to manage image color and color conversion.
Summary
Types
Reference to an ICC color profile
An rbg color expressed as a list of numbers.
A color can be expressed as a list of numbers or as a CSS color name in atom or string format.
A transparency value which is one of the atoms :none
,
:transparent
or :opaque
. Or an integer between 0
and
255
where 0 is transparent and 255 is opaque. Or a float
in the range 0.0
to 1.0
that is converted to the range
0
to 255
.
Functions
Returns a mapping from CSS color names to CSS hex values and RGB triplets as a list.
Returns a mapping from CSS color names to CSS hex values and RGB triplets as a list - but only for greyscal colors.
Converts a hex color string to an RGB 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.
Converts a color name or RGB value to a hex string.
Validates a color returning an
[r, g, b]
triplet or error.
Returns a transparency value in the range 0 to 255 where 0 means transparent and 255 means opqque.
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 profilesPath.t()
means any file system path. If the path is a relative path then is will be loaded from the systems profile directory.
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.
A color can be expressed as a list of numbers or as a CSS color name in atom or string format.
@type transparency() :: :none | :transparent | :opaque | non_neg_integer() | float()
A transparency value which is one of the atoms :none
,
:transparent
or :opaque
. Or an integer between 0
and
255
where 0 is transparent and 255 is opaque. Or a float
in the range 0.0
to 1.0
that is converted to the range
0
to 255
.
Functions
Returns a mapping from CSS color names to CSS hex values and RGB triplets as a list.
Returns a mapping from CSS color names to CSS hex values and RGB triplets as a list - but only for greyscal colors.
Converts a hex color string to an RGB list.
Arguments
color
is a hex string representing an RGB color. It has
the form #RRGGBB
.
Returns
{:ok, [r, g, b]}
or{:error, reason}
.
Examples
iex> Image.Color.validate_color "#0000FF"
{:ok, [0, 0, 255]}
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.
Converts a color name or RGB value to a hex string.
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
{:ok, #RRGGBB}
string or{:error, reason}
.
Examples
iex> Image.Color.rgb_to_hex(:green)
{:ok, "#008000"}
iex> Image.Color.rgb_to_hex([10,20,30])
{:ok, "#A141E"}
Validates a color returning an
[r, g, b]
triplet or error.
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
{:ok, [r, g, b]}
or{:error, reason}
Returns a transparency value in the range 0 to 255 where 0 means transparent and 255 means opqque.