t28hub / auto-palette

🎨 auto-palette is a powerful library for automatic color palette extraction from images. It's available for Rust, Wasm, and as a CLI tool.

Home Page:https://crates.io/crates/auto-palette

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

auto-palette

🎨 auto-palette is a library that automatically extracts prominent color palettes from images, available for Rust ,Wasm and as a CLI tool.

Build License Version Codacy grade Codecov

Features

Hot air balloon on blue sky

Extracted Color Palette

Note

Photo by Laura Clugston on Unsplash

  • Automatically extracts prominent color palettes from images.
  • Provides detailed information on color, position, and population.
  • Supports multiple extraction algorithms, including DBSCAN, DBSCAN++, and KMeans++.
  • Supports multiple color spaces, including RGB, HSL, and LAB.
  • Supports the selection of prominent colors based on multiple themes, including Vivid, Muted, Light, and Dark.
  • Available as a Rust library, Wasm, and a CLI tool.

Installation

Rust

To use auto-palette in your Rust project, add it to your Cargo.toml.

[dependencies]
auto-palette = "0.4.0"

Usage

Here is a basic example that demonstrates how to extract the color palette and find the dominant colors.
See the examples directory for more examples.

use auto_palette::{ImageData, Palette};

fn main() {
  // Load the image data from the file
  let image_data = ImageData::load("tests/assets/holly-booth-hLZWGXy5akM-unsplash.jpg").unwrap();

  // Extract the color palette from the image data
  let palette: Palette<f64> = Palette::extract(&image_data).unwrap();
  println!("Extracted {} swatches", palette.len());

  // Find the 5 dominant colors in the palette and print their information
  let swatches = palette.find_swatches(5);
  for swatch in swatches {
    println!("Color: {}", swatch.color().to_hex_string());
    println!("Position: {:?}", swatch.position());
    println!("Population: {}", swatch.population());
    println!("Ratio: {}", swatch.ratio());
  }
}

Development

See the CONTRIBUTING guidelines.

Contributing

Contributions are welcome! For detailed information on how to contribute, please refer to Contributing guidelines.
Please note that this project is released with a CODE_OF_CONDUCT. By participating in this project you agree to abide by its terms.

License

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

FOSSA Status

About

🎨 auto-palette is a powerful library for automatic color palette extraction from images. It's available for Rust, Wasm, and as a CLI tool.

https://crates.io/crates/auto-palette

License:MIT License


Languages

Language:Rust 100.0%