Image.BackgroundColor (image v0.70.0)

Copy Markdown View Source

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

Types

A background color specification: the image's average color, or any color.

Functions

Resolves a background color spec into a pixel matching image's interpretation and band layout.

Types

spec()

@type spec() :: Image.Pixel.t() | :average

A background color specification: the image's average color, or any color.

Functions

resolve(image, color)

@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

Returns

  • {:ok, [number()]} - the resolved pixel, whose band count matches image (an opaque alpha band is appended for :average when the image has alpha), or

  • {:error, t:Image.Error.t/0}