Skip to content
Extract prominent colors from images. Go port of the Android awesome Palette class aka Vibrant.js.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/vibrant
.gitignore
README.md
bitmap.go
color.go
colorcutquantizer.go
colorhistogram.go
godoc.go
palette.go
priorityqueue.go
swatch.go
vbox.go
webapp.go

README.md

vibrant

godoc reference

Extract prominent colors from images. Go port of the Android awesome Palette class aka Vibrant.js.

screenshot of app.go

install

go get github.com/generaltso/vibrant

usage

// example: create css stylesheet from image file
checkErr := func(err error) { if err != nil { panic(err) } }

f, err := os.Open("some_image.jpg")
checkErr(err)
defer f.Close()

img, _, err := image.Decode(f)
checkErr(err)

palette, err := vibrant.NewPaletteFromImage(img)
checkErr(err)

for name, swatch := range palette.ExtractAwesome() {
  fmt.Printf("/* %s (population: %d) */\n%s\n\n", name, swatch.Population, swatch)
}
output:
/* LightMuted (population: 253) */
.lightmuted{background-color:#cbc0a2;color:#000000;}

/* DarkMuted (population: 11069) */
.darkmuted{background-color:#5b553f;color:#ffffff;}

/* Vibrant (population: 108) */
.vibrant{background-color:#dfd013;color:#000000;}

/* LightVibrant (population: 87) */
.lightvibrant{background-color:#f4ed7d;color:#000000;}

/* DarkVibrant (population: 2932) */
.darkvibrant{background-color:#917606;color:#ffffff;}

/* Muted (population: 4098) */
.muted{background-color:#a58850;color:#000000;}

See godoc reference for full API.

bonus round

reference implementation/command line tool

go get github.com/generaltso/vibrant/cmd/vibrant
usage: vibrant [options] file

options:
  -compress
    	Strip whitespace from output.
  -css
    	Output results in CSS.
  -json
    	Output results in JSON.
  -lowercase
    	Use lowercase only for all output. (default true)
  -rgb
    	Output RGB instead of HTML hex, e.g. #ffffff.

webapp

go get github.com/generaltso/vibrant
cd $GOPATH/src/github.com/generaltso/vibrant
go run webapp.go
# open http://localhost:8080/ in a browser

thanks

https://github.com/Infinity/Iris

This Google I/O 2014 presentation

https://github.com/jariz/vibrant.js

https://github.com/akfish/node-vibrant

You can’t perform that action at this time.