auto-palette

Crates.ioauto-palette
lib.rsauto-palette
version0.3.0
sourcesrc
created_at2024-04-29 13:32:37.992557
updated_at2024-05-19 06:15:54.932467
description🎨 A Rust library that extracts prominent color palettes from images automatically.
homepagehttps://github.com/t28hub/auto-palette
repositoryhttps://github.com/t28hub/auto-palette
max_upload_size
id1224179
size266,833
Tatsuya Maki (t28hub)

documentation

README

auto-palette

🎨 A Rust library for automatically extracting prominent color palettes from images.

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.

Installation

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

[dependencies]
auto-palette = "0.3.0"

Usage

Here is a basic example that demonstrates how to extract the color palette and find the prominent 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("../../gfx/holly-booth-hLZWGXy5akM-unsplash.jpg").unwrap();

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

  // Find the 5 prominent 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());
  }
}

Development

Follow the instructions below to build and test the project:

  1. Fork and clone the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and write tests.
  4. Test your changes with cargo test --lib.
  5. Format the code with cargo +nightly fmt and taplo fmt.
  6. Create a pull request.

License

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

FOSSA Status

Commit count: 127

cargo fmt