func main() { if len(os.Args) <= 1 { println("usage: vibrant [input image]") os.Exit(1) } f, err := os.Open(os.Args[1]) if err != nil { println(err.Error()) os.Exit(1) } img, _, err := image.Decode(f) f.Close() if err != nil { println(err.Error()) os.Exit(1) } palette, err := vibrant.NewPaletteFromImage(img) if err != nil { println(err.Error()) os.Exit(1) } for _, sw := range palette.ExtractAwesome() { fmt.Println(sw.String()) } }
func main() { flag.Usage = usage flag.BoolVar(&output_compress, "compress", false, "Strip whitespace from output.") flag.BoolVar(&output_css, "css", false, "Output results in CSS.") flag.BoolVar(&output_json, "json", false, "Output results in JSON.") flag.BoolVar(&output_lowercase, "lowercase", true, "Use lowercase only for all output.") flag.BoolVar(&output_rgb, "rgb", false, "Output RGB instead of HTML hex, e.g. #ffffff.") flag.Parse() filename := flag.Arg(0) if filename == "" { usage() } f, err := os.Open(filename) checkErr(err) img, _, err := image.Decode(f) f.Close() checkErr(err) palette, err := vibrant.NewPaletteFromImage(img) checkErr(err) switch { case output_json && output_css: usage() case output_json: print_json(palette) case output_css: print_css(palette) default: print_plain(palette) } }