Skip to content

Commit

Permalink
Add small doc and example
Browse files Browse the repository at this point in the history
  • Loading branch information
denisbrodbeck committed Nov 23, 2017
1 parent e13f338 commit 315f007
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Package sqip allows SVG-based LQIP image creation
//
// https://github.com/denisbrodbeck/sqip
//
// https://godoc.org/github.com/denisbrodbeck/sqip/cmd/sqip
//
// TODO
package sqip // import "github.com/denisbrodbeck/sqip"
32 changes: 32 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package sqip_test

import (
"log"
"runtime"

"github.com/denisbrodbeck/sqip"
)

func Example() {
in := "path/to/image.png" // input file
out := "path/to/image.svg" // output file
workSize := 256 // large images get resized to this - higher size grants no boons
count := 8 // number of primitive SVG shapes
mode := 1 // shape type
alpha := 128 // alpha value
repeat := 0 // add N extra shapes each iteration with reduced search (mostly good for beziers)
workers := runtime.NumCPU() // number of parallel workers
background := "" // background color (hex)

svg, width, height, err := sqip.Run(in, workSize, count, mode, alpha, repeat, workers, background)
if err != nil {
log.Fatal(err)
}
// save svg to file
if err := sqip.SaveFile(out, svg); err != nil {
log.Fatal(err)
}
// create example img tag
tag := sqip.ImageTag(out, sqip.Base64(svg), width, height)
log.Print(tag)
}

0 comments on commit 315f007

Please sign in to comment.