Giter VIP home page Giter VIP logo

vibrant's Introduction

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/dayvonjersen/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/dayvonjersen/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/dayvonjersen/vibrant
cd $GOPATH/src/github.com/dayvonjersen/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

vibrant's People

Contributors

dayvonjersen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vibrant's Issues

piping data from another command to vibrant cli

Is it possible to feed an image to the vibrant cli tool from a unix pipe?

ie.

~$ curl https://i.imgur.com/nzcJuDx.png  | vibrant -json 
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.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 16 30609   16  4910    0     0  18374      0  0:00:01 --:--:--  0:00:01 18389
curl: (23) Failed writing body (1945 != 2759)

this does not work ^

I can achieve what I want though by saving to a temp file

eg.

~$ curl https://i.imgur.com/nzcJuDx.png  -o temp && vibrant -json temp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 30609  100 30609    0     0   100k      0 --:--:-- --:--:-- --:--:--  100k
{
  "darkvibrant": {
    "color": "#004285",
    "text": "#ffffff"
  },
  "lightvibrant": {
    "color": "#7bbdff",
    "text": "#000000"
  },
  "vibrant": {
    "color": "#3f9fff",
    "text": "#ffffff"
  }
}

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.