imgpal: Image palettes

View source: R/plot_extra.R

imgpalR Documentation

Image palettes

Description

Extract unique and most commonly-used unique colors from an image file (requires ImageMagick).

Usage

imgpal(path, n = 10L, options = "")

Arguments

path

full file path to image

n

maximum number of colors to extract, result will be <= n, and the calculated number of unique colors will also be provided

options

a (optional) character string of additional options passed to magick

Value

A list of class "imgpal" with the following elements:

filename

the image file name

n_unique

the calculated number of unique colors

col

a vector of colors (does not return transparent or white colors)

counts

frequency counts for each col

call

the call made to magick

magick

the result of call

See Also

show_pal; magick package

Examples

go <- 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'
ip <- imgpal(go)
show_pal(ip, n = 4)

ip <- imgpal(go, options = '-colorize 0,0,50')
show_pal(ip)

## Not run: 
## rawr::rawr_palettes
img <- system.file('fig', package = 'rawr')
img <- list.files(img, full.names = TRUE, pattern = 'g$')

op <- par(mfrow = n2mfrow(length(img)))
sapply(img, function(x) show_pal(imgpal(x), fullrange = TRUE))
par(op)

## End(Not run)


raredd/rawr documentation built on March 4, 2024, 1:36 a.m.