There are fancy ways to extract colours from images but sometimes it’s easier if you could simply click on the image and choose the colours you want.
With eyedroppeR
you can click on an image to return the hex codes of the selected pixels all within R.
Installation
Install from GitHub.
devtools::install_github("doehm/eyedroppeR")
You may also need to install ggchicklet
install.packages("ggchicklet", repos = "https://cinc.rud.is")
For more info follow the link to the GitHub repo.
Usage
Use eyedropper
with the following steps:
- Find the image you want to pick colours from online.
- Right-click and ‘copy image address’.
- Choose how many colours to pick e.g.
n = 5
. - Run
pal <- eyedropper(n = 5)
.eyedropper
will read the copied address from the clipboard ifimg_path
is left as NULL- If you have a local file or a saved
path
you can reference it directly withpal <- eyedropper(n = 5, img_path = path)
- Click the 5 desired colours. The image will be stretched to the borders of the window, but that’s OK.
- Done! Copy the returned string and add it to your script and start using
pal
.

Other functions
sort_pal
: allows you to manually sort a palette by clicking on the colours in order. It also allows you to select a specified number of colours if you don’t want them all.extract_pal
: automatically selects a specified number of colours using a clustering algorithm. It will read the image path from the clipboard as well and allow you to sort the colours after they are extracted.show_pal
: Simple helper to display the palette.