Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
/ go-libwebp Public archive
forked from pixiv/go-libwebp

An implemantaion of Go bindings for libwebp.

License

Notifications You must be signed in to change notification settings

e-conomic/go-libwebp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived

Tech Leads: Repository archived due to inactivity in more than 6 months. Please remember to add a CODEOWNERS file to the root of the repository when unarchiving.

go-libwebp

Build Status GoDoc

A implementation of Go binding for libwebp.

Dependencies

  • libwebp 0.4, 0.5

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.ConfigPreset(webp.PresetDefault, 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) 2016 MICHII Shunsuke. All rights reserved.

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

About

An implemantaion of Go bindings for libwebp.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 96.3%
  • Makefile 2.3%
  • Dockerfile 1.4%