Giter Club home page Giter Club logo

auto-palette's Introduction

auto-palette

๐ŸŽจ auto-palette is a library that automatically extracts prominent color palettes from images, available for Rust ,Wasm and as a CLI tool.

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.
  • Available as a Rust library, Wasm, and a CLI tool.

Installation

Rust

To use 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 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<f32> = 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());
  }
}

Development

See the CONTRIBUTING guidelines.

Contributing

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.

License

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

FOSSA Status

auto-palette's People

Contributors

dependabot[bot] avatar t28hub avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

fossabot

auto-palette's Issues

Inconsistency between code and comment

In auto-palette/src/math/number.rs, the comment Panics if min is greater than or equal to max indicates that the constraint is min < max while the code check min <= max.

/// # Panics
/// Panics if `min` is greater than or equal to `max`.
#[inline]
#[must_use]
pub fn normalize<T>(value: T, min: T, max: T) -> T
where
    T: FloatNumber,
{
    debug_assert!(min <= max, "min must be less than or equal to max");
    (value - min) / (max - min)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.