auto-palette-cli

Crates.ioauto-palette-cli
lib.rsauto-palette-cli
version0.5.0
sourcesrc
created_at2024-05-19 06:16:26.994754
updated_at2024-08-13 14:50:54.243824
description🎨 A CLI tool to extract prominent color palettes from images.
homepagehttps://github.com/t28hub/auto-palette
repositoryhttps://github.com/t28hub/auto-palette
max_upload_size
id1244714
size86,664
Tatsuya Maki (t28hub)

documentation

README

auto-palette-cli

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

Features

  • Extract prominent color palettes from images.
  • Supports multiple color extraction algorithms (dbscan, dbscan++, kmeans). Defaults to dbscan.
  • Supports multiple color selection themes (basic, colorful, vivid, muted, light, dark). Defaults to basic.
  • Supports multiple color formats (hex, rgb, cmyk, hsl, hsv, lab, luv, lchab, lchuv, oklab, oklch, xyz). Defaults to hex.
  • Outputs the color palette in multiple formats (json, text, table). Defaults to text.

Installation

cargo install auto-palette-cli

Usage

$ auto-palette --help
🎨 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.
  -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.

Commit count: 141

cargo fmt