Color extraction utility in Golang
For details information on the utility please look at the following article. Advance Color Quantization with Camalian. This implementation in Golang inspired by Camalian Ruby Implementation.
To use the binary binary for utility. Install it with:
$ GO111MODULE=on go get -u "github.com/nazarhussain/camalian-go/cmd/camalian"
The usage is as follows:
$ camalian --help
Usage:
camalian <path> {flags}
Commands:
help displays usage information
version displays version number
Arguments:
path Path to the image file
Flags:
-h, --help displays usage information of the application or a command (default: false)
-n, --number Number of colors to extract (default: 15)
-q, --quantizer Quantizer to use. histogram, kmeans, median_cut (default: histogram)
-v, --version displays version number (default: false)
Mention the package as your project mode dependencies.
import (
camalian "github.com/nazarhussain/camalian-go"
quantizers "github.com/nazarhussain/camalian-go/quantizers"
Then use as following:
path := "path/to/image/file"
palette := new(camalian.Palette).BuildFromImage(&camalian.Image{FilePath: path})
palette = palette.Quantize(quantizers.Histogram{}, 10)
fmt.Println(palette.ToHex())
Available Quantizers are quantizers.Histogram{}
, quantizers.KMeans{}
and quantizers.MedianCut{}
.
For more details on each quantizers please check this section.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request