Giter Site home page Giter Site logo

swatch-rs's Introduction

swatch-rs

CI

Quantize RGB color space of an image to N dominant colors using a median cut algorithm.

swatch-rs 1.0.0
utility to quantize image to N dominant color using a median cut algorithm.

USAGE:
    swatch-rs [FLAGS] [OPTIONS] --image <image-path>

FLAGS:
    -h, --help            Prints help information
    -m, --most            Get most dominant color of an image
    -o, --output-image    whether output quantized image or not. if true, it will create a file called
                          "${filename}-quantized.png"
    -V, --version         Prints version information

OPTIONS:
    -d, --debug-type <debug-type>    Debug type print quantized pixels to given format. value can be (html or json).
                                     "html" debug type will create a "swatch-${file_name}.html" and write HTML data into
                                     it [default: json]
    -i, --image <image-path>         Path to an image
    -c, --colors <max-depth>         Number of colors needed in power of 2, ex: for 16 colors pass 4. (i.e. 2^4 = 16)
                                     [default: 4]

Download

  • Download appropriate pre-compiled binary from the release page.
# download tar archive using cURL
curl -L https://github.com/urvil38/swatch-rs/releases/download/v1.0.0/swatch-rs-v1.0.0-x86_64-linux.tar.gz > swatch-rs-v1.0.0-x86_64-linux.tar.gz

# untar archive
tar -xvzf swatch-rs-v1.0.0-x86_64-linux.tar.gz
cd swatch-rs

# move it to bin dir (user need to have root privileges. Run the following command as root using sudo.
sudo mv ./swatch-rs /usr/local/bin

Build

  • You can compile from source by installing Cargo (Rust's package manager) and building swatch-rs using Cargo:
git clone https://github.com/urvil38/swatch-rs.git
cd swatch-rs
cargo build --release

Compilation will probably take a few minutes depending on your machine. The binary will end up in ./target/release/swatch-rs.

Example

Image: iceland.jpg - dimention: 1920 × 1080 - size: 1.1 Mib

iceland.jpg

  • The following command will produce a quantized image and swatch.html file, which contains top N dominant colors(sorted by luminance).
swatch-rs -i ./docs/iceland.jpg -d html -c 4 -o

swatch.html

Image: quantize-image.jpg - dimention: 1920 × 1080 - size: 418 Kib

quantize-image

swatch-rs's People

Contributors

urvil38 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

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.