OpenBI Docs Buy

Image.Color OpenBI

One dominant colour of a picture, written #RRGGBB: the first, or the one at the rank you ask for.

Group: Images and colours. OpenBI’s own: Power Query M has no function of this name.

Syntax

Image.Color(image as any, optional options as nullable record) as nullable text
ParameterTypeDescription
imageanyThe image's bytes (File.Contents, Web.Contents), or text: an http:// or https:// address, a data: URI or base 64.
optionsnullable record
optional
Rank (1 unless you give another), and the options of Image.Colors.

Returns

nullable text. The colour as #RRGGBB; null past the colours found, or for a null image.

Remarks

  • The same colours Image.Colors finds, in the same order: Image.Color(x, [Rank = 2]) is the second row's Color.
  • Useful in Table.AddColumn, for a column of each product photo's main colour.

Compared with Power Query

An OpenBI function: Power Query has none like it, so a query that uses it runs in OpenBI only, not in Power BI Desktop or the Power BI service.

Examples

The main colour

Image.Color(File.Contents("C:\Data\swatch.png"))
"#7B2D3B"

The second

Image.Color(File.Contents("C:\Data\swatch.png"), [Rank = 2])
"#D4A017"

Past the colours found

Image.Color(File.Contents("C:\Data\swatch.png"), [Rank = 5])
null

The swatch has two colours once white is left out.

Image.Colors, Color.Name.

Last updated · OpenBI Studio 0.3.79