Code Monkey home page Code Monkey logo

image-palette-tools's Introduction

image-palette-tools (WIP)

image-palette-tools is a set of related image tools:

  • extract-palette - generates a color palette from an image
  • cluster-by-palette - clusters a set of images by their color palettes

The tools support PNG, JPEG, and GIF images.

Image Palette (k=5)
img1 img1-palette
img2 img2-palette
img3 img3-palette

Get it

Using go get:

go get -u github.com/sgreben/image-palette-tools/cmd/extract-palette
go get -u github.com/sgreben/image-palette-tools/cmd/cluster-by-palette

Or download the binaries from the releases page.

# Linux
curl -L https://github.com/sgreben/image-palette-tools/releases/download/0.0.1/extract-palette_0.0.1_linux_x86_64.tar.gz | tar xz
curl -L https://github.com/sgreben/image-palette-tools/releases/download/0.0.1/cluster-by-palette_0.0.1_linux_x86_64.tar.gz | tar xz

# OS X
curl -L https://github.com/sgreben/image-palette-tools/releases/download/0.0.1/extract-palette_0.0.1_osx_x86_64.tar.gz | tar xz
curl -L https://github.com/sgreben/image-palette-tools/releases/download/0.0.1/cluster-by-palette_0.0.1_osx_x86_64.tar.gz | tar xz

# Windows
curl -LO https://github.com/sgreben/image-palette-tools/releases/download/0.0.1/extract-palette_0.0.1_windows_x86_64.zip
unzip extract-palette_0.0.1_windows_x86_64.zip

curl -LO https://github.com/sgreben/image-palette-tools/releases/download/0.0.1/cluster-by-palette_0.0.1_windows_x86_64.zip
unzip cluster-by-palette_0.0.1_windows_x86_64.zip

Use it

extract-palette

Usage of extract-palette:
  -k int
        number of colors to extract (default 8)
  -out-json value
        path of output JSON file (go template)
  -out-png value
        path of output palette image (PNG) (go template)
  -out-png-height int
        size of each color square in the palette output image (default 100)
  -out-txt value
        path of output text file (go template)
  -p int
        number of images to process in parallel (default 8)

Examples

For each image file, extract an 8-color palette. Generate a PNG image of the palette with suffix -palette-8.png. Write a JSON file containing the palette colors to a file with suffix -palette-8.json.

extract-palette \
      -k 8 \
      -out-png '{{.Path}}-pallette-{{.K}}.png' \
      -out-json '{{.Path}}-pallette-{{.K}}.json' \
      *.jpg

cluster-by-palette

Usage of cluster-by-palette:
  -n int
        number of image clusters to make (default 5)
  -glob value
        glob expression matching image files to cluster
  -k int
        palette size (default 4)
  -out-shell value
        shell command to run for each image (go template)
  -out-summary-json value
        path of output JSON containing the clustering (go template)
  -out-cluster-png value
        output path for cluster palette image (PNG) (go template)
  -out-cluster-png-height int
        size of each color square in the palette output image (default 100)
  -in-json value
        path to read palette JSON from (go template)
  -out-json value
        path to write palette JSON to (go template)
  -p int
        number of images to process in parallel (default 8)

Examples

Create 8 clusters of images based on their 4-color palettes. Make directories cluster-0...cluster-7 and copy the files to their respective cluster's directory. For each cluster, create PNG palette images named cluster-8-0.png...cluster-8-7.png.

cluster-by-palette \
      -n 8 \
      -k 4 \
      -out-shell 'd="cluster-{{.Label}}"; mkdir -p "$d"; cp "{{.Path}}" "$d"' \
      -out-cluster-png "cluster-{{.N}}-{{.Label}}.png" \
      *.jpg

Comments

Feel free to leave a comment or create an issue.

image-palette-tools's People

Contributors

sgreben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

image-palette-tools's Issues

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.