https://github.com/marekm4/dominant_color
Simple image color extractor written in Rust with no external dependencies
https://github.com/marekm4/dominant_color
color color-extratcion palette-generation rust
Last synced: 7 months ago
JSON representation
Simple image color extractor written in Rust with no external dependencies
- Host: GitHub
- URL: https://github.com/marekm4/dominant_color
- Owner: marekm4
- License: mit
- Created: 2019-06-28T18:55:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T11:03:03.000Z (over 2 years ago)
- Last Synced: 2024-10-06T17:07:46.037Z (about 1 year ago)
- Topics: color, color-extratcion, palette-generation, rust
- Language: Rust
- Homepage:
- Size: 133 KB
- Stars: 34
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust - marekm4/dominant_color
README
# dominant_color
Simple image color extractor written in Rust with no external dependencies
## Install
```
cargo add dominant_color
```
## Usage
```rust
use std::path;
use image::EncodableLayout;
fn main() {
let image = image::open(path::Path::new("docs/Fotolia_45549559_320_480.jpg")).unwrap();
// if you are sure that you are using RGB image
let colors = dominant_color::get_colors(image.as_bytes(), false);
println!("{:?}", colors);
// if you are not sure
let colors = dominant_color::get_colors(image.to_rgb8().as_bytes(), false);
println!("{:?}", colors);
// if image has alpha channel
let colors = dominant_color::get_colors(image.to_rgba8().as_bytes(), true);
println!("{:?}", colors);
}
```
## Example


## Demo
https://dominant-color-demo.marekm4.com/