| Crates.io | colorgram |
| lib.rs | colorgram |
| version | 1.0.1 |
| created_at | 2025-05-09 03:46:01.864305+00 |
| updated_at | 2026-01-06 03:40:11.688472+00 |
| description | Rust library that extracts colors from image. Port of colorgram.py |
| homepage | https://github.com/arabianq/colorgram-rust |
| repository | https://github.com/arabianq/colorgram-rust |
| max_upload_size | |
| id | 1666185 |
| size | 636,840 |
colorgram-rust is a rust program that lets you extract colors from image. It is a port of colorgram.py (which is itself a port of colorgram.js, so it's basically a port of a port =D)
Why? Well, it's ~25 times faster than colorgram.py (9 ms vs 225 ms for test.png on my laptop)
cargo install colorgram
[dependencies]
colorgram = "0.1.0"
use colorgram::extract;
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let buf = fs::read("image.jpg")?;
let colors = extract(&buf, 5)?;
for color in colors {
println!("Color: {}, Weight: {:.2}%", color.rgb, color.proportion * 100.0);
}
Ok(())
}