#color-palette #image #color #graphics #palette #color-extraction

app auto-palette-cli

🎨 A CLI tool to extract prominent color palettes from images

5 releases (breaking)

new 0.7.0 Mar 26, 2025
0.6.0 Feb 15, 2025
0.5.0 Aug 13, 2024
0.4.0 Jun 7, 2024
0.3.0 May 19, 2024

#96 in Images

Download history 3/week @ 2024-12-06 1/week @ 2024-12-13 118/week @ 2025-02-14 4/week @ 2025-02-21 7/week @ 2025-02-28 56/week @ 2025-03-21

64 downloads per month

MIT license

305KB
7K SLoC

auto-palette-cli

🎨 A CLI tool to extract color palettes from images using the auto-palette crate.

Build License Version

Features

  • Extract prominent color palettes from images.
  • Supports multiple color extraction algorithms: dbscan, dbscan++, and kmeans. (default: dbscan).
  • Flexible theme selection for color swatches: basic, colorful, vivid, muted, light, and dark. (default: basic).
  • Supports multiple color formats (hex, rgb, cmyk, hsl, hsv, lab, luv, lchab, lchuv, oklab, oklch, xyz). Defaults to hex.
  • Multiple output formats: json, text, and table. (default: text).
  • Clipboard support for instant palette extraction.

Installation

cargo install auto-palette-cli

Quick Start

Extract a simple 5 color palette from an image:

auto-palette path/to/your_image.jpg

Extract a 5 color palette from an image using the vivid theme and rgb color format with table output format:

auto-palette path/to/your_image.jpg -n 5 -a dbscan++ -t vivid -c rgb -o table

Extract a color palette from clipboard image:

auto-palette --clipboard

Usage

$ auto-palette -h
🎨 A CLI tool to extract prominent color palettes from images.

Usage: auto-palette [OPTIONS] <PATH>

Arguments:
  <PATH>  Path to the image file.

Options:
  -a, --algorithm <name>  Algorithm for extracting the color palette. [default: dbscan] [possible values: dbscan, dbscan++, kmeans]
  -t, --theme <name>      Theme for selecting the swatches. [possible values: basic, colorful, vivid, muted, light, dark]
  -n, --count <number>    Number of colors to extract. [default: 5]
  -c, --color <name>      Output color format. [default: hex] [possible values: hex, rgb, cmyk, hsl, hsv, lab, luv, lchab, lchuv, oklab, oklch, xyz]
  -o, --output <name>     Output format. [default: text] [possible values: json, text, table]
      --no-resize         Disable image resizing before extracting the color palette.
      --clipboard         Get image from system clipboard
  -h, --help              Print help (see more with '--help')
  -V, --version           Print version

Examples

Basic usage

Here is an example of extracting the color palette from an image:

$ auto-palette path/to/your_image.jpg
   #EB3739 (82, 293) 7751
   #A24F01 (114, 129) 132 
   #FB9C04 (96, 155) 112 
   #D25A6E (58, 228) 20  
   #8DA502 (94, 84) 16  

Advanced usage

Here is an example of extracting the color palette from an image using the vivid theme, the rgb color format, and the table output format:

$ auto-palette path/to/your_image.jpg -t vivid -n 6 -c rgb -o table
+---+--------------------+------------+------------+
| # | Color              | Position   | Population |
+---+--------------------+------------+------------+
| 1 | RGB(221, 226, 222) | (104, 96)  |       6778 |
| 2 | RGB(3, 144, 149)   | (114, 201) |       5476 |
| 3 | RGB(23, 37, 36)    | (120, 300) |       4300 |
| 4 | RGB(36, 88, 131)   | (183, 145) |       1348 |
| 5 | RGB(254, 29, 44)   | (183, 190) |        779 |
| 6 | RGB(253, 213, 116) | (25, 158)  |        567 |
+---+--------------------+------------+------------+

Development

Building

cargo run -- {image_path}

Testing

cargo nextest run --tests --all-features --package auto-palette-cli

License

This project is distributed under the MIT license. See the LICENSE file for more details.

Dependencies

~6–18MB
~275K SLoC