slinso / palitra

Utility that finds the N most frequent colors in a picture, approximated to CSS3 color names

Home Page:https://godoc.org/github.com/jkomyno/palitra

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

palitra

Build Status GoDoc Go Report Card

Example image

Description

Utility that finds the N most frequent colors in a picture, approximated to CSS3 color names. Palitra is available both as a plain library, and as a CLI tool (which also supports input from stdin, via pipe). It requires Go 1.8.

Install

You can download the library with go get:

$ go get github.com/jkomyno/palitra

If you want to use the CLI tool, then you can type the following to install it in your environment.

$ go install github.com/jkomyno/palitra/cmd/palitra

Usage

CLI

This guide assumes that palitra is installed globally.

Here's how palitra --help looks like:

Usage of C:\Work\GoWorkspace\bin\palitra.exe:
  -img string
        the name of the image file to get colors from
  -n int
        the number of the most dominant CSS3 colors to extract (default 3)
  -r uint
        the resized width to process the image quicker (default 75)

If you're ok with the default values, then you can simply pipe an image to palitra. Example:

$ cat ./test_images/venice.jpg | palitra

The result should look like the following:

1) lightpink: 10.48%
2) lightslategrey: 9.97%
3) dimgrey: 9.61%

Completed in 679.7955ms ✨

If not, you can manually specify the parameters as you like:

$ palitra -img ./test_images/venice.jpg -n 5 -r 50

The result should look like the following:

1) lightpink: 10.34%
2) dimgrey: 10.04%
3) lightslategrey: 9.93%
4) silver: 9.15%
5) darkslategrey: 8.81%

Completed in 290.7805ms ✨

Library

For the library usage, please refer to godoc. You can import the library in the following way:

import "github.com/jkomyno/palitra"

Testing

$ go test -v -bench=.

License

The MIT License (MIT). Please see License File for more information.

About

Utility that finds the N most frequent colors in a picture, approximated to CSS3 color names

https://godoc.org/github.com/jkomyno/palitra

License:MIT License


Languages

Language:Go 100.0%