Resolves an Image.Pixel.t() / :average value into a concrete pixel in the
image's colorspace.
A background color specification is either the atom :average (the average
color of the image), or any color accepted by
Image.Pixel.to_pixel/2 (a Color struct, a hex string, a CSS named color,
an atom or a list of numbers).
In both cases the resolved pixel matches image's number of bands.
Summary
Functions
Resolves a background color spec into a pixel matching image's
interpretation and band layout.
Types
@type spec() :: Image.Pixel.t() | :average
A background color specification: the image's average color, or any color.
Functions
@spec resolve(Vix.Vips.Image.t(), spec()) :: {:ok, [number()]} | {:error, Image.Error.t()}
Resolves a background color spec into a pixel matching image's
interpretation and band layout.
Arguments
imageis anyVix.Vips.Image.t/0.specis:average(the image's average color) or any color accepted byImage.Pixel.to_pixel/2.
Returns
{:ok, [number()]}- the resolved pixel, whose band count matchesimage(an opaque alpha band is appended for:averagewhen the image has alpha), or{:error, t:Image.Error.t/0}
Examples
iex> image = Image.new!(3, 3, color: :red)
iex> Image.BackgroundColor.resolve(image, :average)
{:ok, [255, 0, 0]}
iex> Image.BackgroundColor.resolve(image, :blue)
{:ok, [0, 0, 255]}
iex> Image.BackgroundColor.resolve(image, "#00ff00")
{:ok, [0, 255, 0]}