mirror of
https://github.com/talgo-cloud/talgo-libwebp.git
synced 2026-03-07 21:48:16 -08:00
initial commit
This commit is contained in:
commit
5af6d93b3b
26 changed files with 1165 additions and 0 deletions
32
examples/encode/encode.go
Normal file
32
examples/encode/encode.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"image"
|
||||
|
||||
"github.com/harukasan/go-libwebp/examples/util"
|
||||
"github.com/harukasan/go-libwebp/webp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
img := util.ReadPNG("cosmos.png")
|
||||
|
||||
// Create file and buffered writer
|
||||
io := util.CreateFile("encoded_cosmos.webp")
|
||||
w := bufio.NewWriter(io)
|
||||
defer func() {
|
||||
w.Flush()
|
||||
io.Close()
|
||||
}()
|
||||
|
||||
config := webp.Config{
|
||||
Preset: webp.PresetDefault,
|
||||
Quality: 90,
|
||||
Method: 6,
|
||||
}
|
||||
|
||||
// Encode into WebP
|
||||
if err := webp.EncodeRGBA(w, img.(*image.RGBA), config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue