Skip to content

nazarhussain/camalian-go

Repository files navigation

Camalian-Go

Go Report Card GitHub license Build codecov

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.

Usage

Binary Usage

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)

Library Usage

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.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Color extraction utility in Golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages