No description
Find a file
2016-06-08 20:09:46 +09:00
examples Update comments 2015-01-09 18:02:14 +09:00
test/util Try to find example files in multiple directories which contains $GOPATH. 2015-01-09 16:59:41 +09:00
webp Support rules for passing pointers between Go with C for Go 1.6 2016-01-27 16:07:31 +09:00
.gitignore initial commit 2015-01-09 12:52:13 +09:00
.travis.yml Add test for Go 1.5 - tip and libwebp 4.3 - 5.0 2016-06-08 20:09:46 +09:00
LICENSE initial commit 2015-01-09 12:52:13 +09:00
README.md Add Godoc badge. 2015-01-09 21:05:59 +09:00

go-libwebp

Build Status GoDoc

A implementation of Go binding for libwebp written with cgo.

Usage

The examples directory contains example codes and images.

Decoding WebP into image.RGBA

package main

import (
	"github.com/harukasan/go-libwebp/test/util"
	"github.com/harukasan/go-libwebp/webp"
)

func main() {
	var err error

	// Read binary data
	data := util.ReadFile("cosmos.webp")

	// Decode
	options := &webp.DecoderOptions{}
	img, err := webp.DecodeRGBA(data, options)
	if err != nil {
		panic(err)
	}

	util.WritePNG(img, "encoded_cosmos.png")
}

You can set more decoding options such as cropping, flipping and scaling.

Encoding WebP from image.RGBA

package main

import (
	"bufio"
	"image"

	"github.com/harukasan/go-libwebp/test/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,
	}

	// Encode into WebP
	if err := webp.EncodeRGBA(w, img.(*image.RGBA), config); err != nil {
		panic(err)
	}
}

TODO

  • Incremental decoding API
  • Container API (Animation)

License

Copyright (c) 2014 MICHII Shunsuke. All rights reserved.

This library is released under The BSD 2-Clause License. See LICENSE.