-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e13f338
commit 315f007
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |