Crates.io | auto-palette-wasm |
lib.rs | auto-palette-wasm |
version | 0.4.0 |
source | src |
created_at | 2024-05-19 06:16:47.19941 |
updated_at | 2024-06-07 10:12:39.326966 |
description | 🎨 A WebAssembly binding for auto-palette, allowing it to automatically extract color palettes from images. |
homepage | https://github.com/t28hub/auto-palette |
repository | https://github.com/t28hub/auto-palette |
max_upload_size | |
id | 1244715 |
size | 21,592 |
🎨
auto-palette
is a library that automatically extracts prominent color palettes from images, available for Rust ,Wasm and as a CLI tool.
[!NOTE] Photo by Laura Clugston on Unsplash
DBSCAN
, DBSCAN++
, and KMeans++
.RGB
, HSL
, and LAB
.Vivid
, Muted
, Light
, and Dark
.To use auto-palette
in your Rust project, add it to your Cargo.toml
.
[dependencies]
auto-palette = "0.4.0"
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());
}
}
See the CONTRIBUTING guidelines.
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.
This project is distributed under the MIT License. See the LICENSE file for details.