#color-palette #image #graphics #color #algorithm #dominant #representative

color-thief

Grabs the dominant color or a representative color palette from an image

4 releases

Uses old Rust 2015

0.2.2 Jun 4, 2022
0.2.1 Jul 17, 2020
0.2.0 Jun 25, 2020
0.1.0 Aug 1, 2017

#227 in Images

Download history 2227/week @ 2024-07-27 2147/week @ 2024-08-03 2653/week @ 2024-08-10 2631/week @ 2024-08-17 2088/week @ 2024-08-24 2431/week @ 2024-08-31 2324/week @ 2024-09-07 2328/week @ 2024-09-14 2816/week @ 2024-09-21 2349/week @ 2024-09-28 1975/week @ 2024-10-05 2869/week @ 2024-10-12 2835/week @ 2024-10-19 3475/week @ 2024-10-26 2520/week @ 2024-11-02 2129/week @ 2024-11-09

11,546 downloads per month
Used in 14 crates (8 directly)

MIT license

525KB
415 lines

color-thief-rs

color-thief-rs is a color-thief algorithm reimplementation in Rust.

The implementation itself is a heavily modified Swift version of the same algorithm.

Differences

  • There is no getColor method, since it's just a shorthand for getPalette.
  • Output colors are a bit different from JS version. See tests for details.

Performance

About 150x faster that JS version.

test q1  ... bench:   1,429,800 ns/iter (+/- 21,987)
test q10 ... bench:     854,297 ns/iter (+/- 25,468)

Usage

Dependency: Rust >= 1.13

Add this to your Cargo.toml:

[dependencies]
color-thief = "0.2"

License

color-thief-rs is licensed under the MIT.


lib.rs:

color-thief-rs is a color-thief algorithm reimplementation in Rust.

The implementation itself is a heavily modified Swift version of the same algorithm.

Dependencies