• Stars
    star
    447
  • Rank 97,700 (Top 2 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WebP decoder and encoder for Go (Zero Dependencies).
  • Go่ฏญ่จ€QQ็พค: 102319854, 1055927514
  • ๅ‡น่ฏญ่จ€(ๅ‡น่ฏป้Ÿณโ€œWaโ€)(The Wa Programming Language): https://github.com/wa-lang/wa

webp

โ–ˆโ–ˆโ•—    โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•‘    โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•‘ โ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•
โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•
โ•šโ–ˆโ–ˆโ–ˆโ•”โ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘
 โ•šโ•โ•โ•โ•šโ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•

Build Status GoDoc

Benchmark

Install

Install GCC or MinGW (download here) at first, and then run these commands:

  1. go get github.com/chai2010/webp
  2. go run hello.go

Example

This is a simple example:

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"log"

	"github.com/chai2010/webp"
)

func main() {
	var buf bytes.Buffer
	var width, height int
	var data []byte
	var err error

	// Load file data
	if data, err = ioutil.ReadFile("./testdata/1_webp_ll.webp"); err != nil {
		log.Println(err)
	}

	// GetInfo
	if width, height, _, err = webp.GetInfo(data); err != nil {
		log.Println(err)
	}
	fmt.Printf("width = %d, height = %d\n", width, height)

	// GetMetadata
	if metadata, err := webp.GetMetadata(data, "ICCP"); err != nil {
		fmt.Printf("Metadata: err = %v\n", err)
	} else {
		fmt.Printf("Metadata: %s\n", string(metadata))
	}

	// Decode webp
	m, err := webp.Decode(bytes.NewReader(data))
	if err != nil {
		log.Println(err)
	}

	// Encode lossless webp
	if err = webp.Encode(&buf, m, &webp.Options{Lossless: true}); err != nil {
		log.Println(err)
	}
	if err = ioutil.WriteFile("output.webp", buf.Bytes(), 0666); err != nil {
		log.Println(err)
	}
    
    fmt.Println("Save output.webp ok")
}

Decode and Encode as RGB format:

m, err := webp.DecodeRGB(data)
if err != nil {
	log.Fatal(err)
}

data, err := webp.EncodeRGB(m)
if err != nil {
	log.Fatal(err)
}

Notes

Change the libwebp to fast method:

internal/libwebp/src/enc/config.c
WebPConfigInitInternal
config->method = 0; // 4;

BUGS

Report bugs to [email protected].

Thanks!

More Repositories

1

advanced-go-programming-book

๐Ÿ“š ใ€ŠGo่ฏญ่จ€้ซ˜็บง็ผ–็จ‹ใ€‹ๅผ€ๆบๅ›พไนฆ๏ผŒๆถต็›–CGOใ€Goๆฑ‡็ผ–่ฏญ่จ€ใ€RPCๅฎž็Žฐใ€Protobufๆ’ไปถๅฎž็Žฐใ€Webๆก†ๆžถๅฎž็Žฐใ€ๅˆ†ๅธƒๅผ็ณป็ปŸ็ญ‰้ซ˜้˜ถไธป้ข˜(ๅฎŒ็จฟ)
Handlebars
18,653
star
2

go-ast-book

๐Ÿ“š ใ€ŠGo่ฏญ่จ€ๅฎšๅˆถๆŒ‡ๅ—ใ€‹(ๅŽŸๅ๏ผšGo่ฏญๆณ•ๆ ‘ๅ…ฅ้—จ/ๅผ€ๆบๅ…่ดนๅ›พไนฆ/Go่ฏญ่จ€่ฟ›้˜ถ/ๆŽŒๆกๆŠฝ่ฑก่ฏญๆณ•ๆ ‘/Go่ฏญ่จ€AST)
Go
5,233
star
3

awesome-wasm-zh

WebAssembly(wasm)่ต„ๆบ็ฒพ้€‰
WebAssembly
976
star
4

gopherchina2018-cgo-talk

๐Ÿ“– GopherChina2018: ๆทฑๅ…ฅCGO็ผ–็จ‹ - ๆœ€ๆ–ฐไฟฎ่ฎข
JavaScript
334
star
5

ptyy

่Ž†็”ฐๅŒป้™ข: ่Ž†็”ฐ็ณป ้‡Ž้ธกๅŒป้™ข ๆŸฅ่ฏข (iOS/Swift/Go/Ruby/)
Go
153
star
6

pbgo

๐Ÿ’ป pbgo is a mini RPC/REST/Grpc-Gateway framework based on Protobuf
Go
120
star
7

opencv

Go bindings for OpenCV1.1 (Dev/Zero Dependencies).
C++
116
star
8

guetzli-go

Guetzli perceptual JPEG encoder for Go (Zero Dependencies).
Go
86
star
9

cgo

golang cgo helper
Go
82
star
10

gettext-go

๐Ÿ†Ž GNU gettext for Go (Imported By Kubernetes)
Go
82
star
11

tinylang

Tiny็Žฉๅ…ท่ฏญ่จ€(Go่ฏญ่จ€ๅฎž็Žฐ/ๅŒ…ๅซTiny็ผ–่ฏ‘ๅ™จ/CASLๆฑ‡็ผ–ๅ™จ/COMET่™šๆ‹Ÿๆœบ/่ฐƒ่ฏ•ๅ™จ/ๆ”ฏๆŒWebAssembly/LLVM)
Go
67
star
12

protorpc

prtorpc(2013-2021): Google Protocol Protobufs RPC for Go.
Go
61
star
13

notepadplus-go

notepad++ support Go language and Go assembly language (Windows).
55
star
14

wasm-book-code

WebAssemblyๆ ‡ๅ‡†ๅ…ฅ้—จ ไปฃ็ 
JavaScript
54
star
15

tiff

Rich TIFF/BigTIFF/GeoTIFF decoder/encoder for Go (Pure Go/Zero Dependencies)
Go
50
star
16

errors

Go errors process, support error code, caller info, json format and wraped error.
Go
40
star
17

gotlang

๐Ÿถ๐Ÿถ๐Ÿถ ็‹—ๅคด่ฏญ่จ€๏ผˆgotlang๏ผ‰ ๐Ÿถ๐Ÿถ๐Ÿถ
Go
38
star
18

base60

base60: ๅคฉๅนฒๅœฐๆ”ฏ็ผ–็ : ไน™ไธ‘็™ธๅทณ็”ฒๅฏ…ๅทฑไบฅไธๅฏ็”ฒ็”ณไธๆœช็”ฒๅˆๅทฑๅทณ
Go
35
star
19

notepadplus-protobuf

notepad++ support Protobuf (Windows).
32
star
20

libfacedetection-go

libfacedetection binding for Go
C++
32
star
21

guetzli-js

Guetzli for NodeJS/Browser
C++
28
star
22

calculator

ๅŸบไบŽflex&goyaccๅฎž็Žฐ็š„่ฎก็ฎ—ๅ™จ
Go
28
star
23

leetcode-go

๐Ÿ’ปLeetCode็ปƒไน , Go่ฏญ่จ€็‰ˆๆœฌ
Go
24
star
24

coder-books

๐Ÿ“š ็ ๅ†œ็›ธๅ…ณ็š„็ปๅ…ธๅ›พไนฆๆ”ถ้›†
21
star
25

bpg

BPG decoder for Go (Zero Dependencies).
Go
20
star
26

ugo-rs

ยตGo็ผ–็จ‹่ฏญ่จ€(Rust็‰ˆๆœฌ) - ่ฏ•้ชŒๅœบ
Rust
20
star
27

qrcode

QR code encoder/decoder
Go
18
star
28

defer

Go's defer operator for C++
C++
16
star
29

notepadplus-typescript

notepad++ support TypeScript (Windows).
TypeScript
14
star
30

chai2010.github.io

๐Ÿ“– chai2010 ็š„ๅšๅฎข
JavaScript
13
star
31

asmgo-talk

Goๆฑ‡็ผ–่ฏญ่จ€็ฎ€ไป‹
JavaScript
12
star
32

gopl-notes-zh

๐Ÿ“š Go่ฏญ่จ€ๅœฃ็ป่ฏปไนฆ็ฌ”่ฎฐ
Makefile
11
star
33

awesome-cue-zh

๐Ÿ“š CUE้…็ฝฎ่ฏญ่จ€่ต„ๆบ็ฒพ้€‰(ๆฌข่ฟŽๆŠ•็จฟ)
Go
11
star
34

cache

LevelDB style LRU cache for Go, support non GC object.
Go
11
star
35

im4corner

Google่พ“ๅ…ฅๆณ•ๅ››่ง’ๅท็ ๆ‰ฉๅฑ•
Lua
10
star
36

qml

Qt/QML for Golang (fork from go-qml/qml.v1), Qt/MSVC with Win32/Win64.
Go
10
star
37

protorpc.cxx

This package provides C++ Protobuf-RPC support.
C++
10
star
38

lucky-star

ๅนธ่ฟไน‹ๆ˜Ÿ: ๅ…ฌๅนณๅ…ฌๆญฃ็š„ๆŠฝๅฅ–็ฎ—ๆณ•
Go
9
star
39

glua-strings

Go strings package for gopher-lua
Go
8
star
40

bzip2

bzip2 compression for Go
Go
8
star
41

ethutil

โ™ฆฮžโ™ฆ ไปฅๅคชๅŠๅทฅๅ…ท็ฎฑ(้›ถ็ฌฌไธ‰ๆ–นๅบ“ไพ่ต–) โ™ฆฮžโ™ฆ
Go
7
star
42

mdbook-go

mdBook: Go่ฏญ่จ€่ฟทไฝ ็‰ˆๆœฌ
CSS
6
star
43

logger

Package logger implements a simple level logging package.
Go
6
star
44

ditaa-docker

docker container for ditaa
Makefile
6
star
45

jsonv

Get Value from JSON
Go
6
star
46

wqy-microhei-go

Go่ฏญ่จ€ๆ–‡ๆณ‰้ฉฟๅพฎ็ฑณ้ป‘ๅญ—ไฝ“
Go
5
star
47

glua-helper

GopherLua helper function
Go
5
star
48

FGPTL

FUCK GPT License(GPT ็ฆๆญขๅ่ฎฎ)
5
star
49

goapp-in-docker

Building Minimal Docker Containers for Go App
Go
5
star
50

chai2010

4
star
51

protorpc3-cxx

This package provides C++ Protobuf3-RPC support.
C++
4
star
52

wc

ๅŸบไบŽflexๅฎž็Žฐ็š„wcๅ‘ฝไปค, ๅ•่ฏ่ฎกๆ•ฐ
Go
4
star
53

jsonmap

Map for json/struct/key-value-db
Go
4
star
54

assert

Assert for Go1.9+
Go
4
star
55

builtin

Provides some usefull functions for Go.
Go
4
star
56

wa-example-p5

ๅ‡น่ฏญ่จ€P5ๅ„ฟ็ซฅ็ผ–็จ‹ p5.wa is a friendly tool for learning to code and make art.
JavaScript
4
star
57

kusion-cookbook

๐Ÿ“š KusionStackไบ‘ๅŽŸ็”Ÿๅ…ซๅฆ
3
star
58

talks

my talk slides
CSS
3
star
59

pbgo-grpc

pbgo grpc/rest examples
Go
3
star
60

ethrpc

โ™ฆฮžโ™ฆ ไปฅๅคชๅŠ่ฝป้‡็บงRPCๅฎขๆˆท็ซฏ(ๅผ€ๅ‘ไธญ) โ™ฆฮžโ™ฆ
Go
3
star
61

spacestring

space string contains more than 1 space characters
Go
3
star
62

brainfuck

brainfuck VM
Go
3
star
63

wa-example-magnifying-glass

ๅ‡น่ฏญ่จ€ๅฎž็Žฐๆ”พๅคง้•œ
JavaScript
3
star
64

vscode-extdev-book

๐Ÿ“š ใ€ŠVS Code ๆ’ไปถๅผ€ๅ‘ใ€‹
Makefile
3
star
65

emscripten-talk

Emscripten็ฎ€ไป‹
JavaScript
2
star
66

theia-ide-book

๐Ÿ“š TheiaIDEๅ‚่€ƒๆ‰‹ๅ†Œ
2
star
67

protoc

protoc wrap, support `go get`
C++
2
star
68

version

get go-app version
Go
2
star
69

ini

INI configuration file parser
Go
2
star
70

vimpinyin

Vimๆ‹ผ้Ÿณ่พ“ๅ…ฅๆณ•
Lua
2
star
71

cc-mini-test

C++ Mini UnitTest and Benchmark Library
C++
2
star
72

wa-example-canvas

ๅ‡น่ฏญ่จ€Canvasไพ‹ๅญ
JavaScript
2
star
73

wa-example-life

ๅ‡น่ฏญ่จ€็”Ÿๅ‘ฝๆธธๆˆไพ‹ๅญ
JavaScript
2
star
74

template

template helper
Go
2
star
75

ibox-docker

dockerๅทฅๅ…ท็ฎฑ
Dockerfile
1
star
76

rust-base60

encodes and decodes base60 as bytes or utf8
Rust
1
star
77

ghutil

ghutil
Go
1
star
78

ArduinoMegaRTOS

FreeRTOS on Arduino Mega
C
1
star
79

lzfse-go

LZFSE decoder and encoder for Go (Zero Dependencies).
C
1
star
80

bench

Go
1
star
81

xmc-builder

xmc-builder
Dockerfile
1
star
82

protoc-gen-grpc-plugins

1
star
83

etcd-docker

etcd docker image
Makefile
1
star
84

etcdfs

(WIP)virtual file system on etcd
Go
1
star
85

image

Package image implements a basic 2-D image library.
Go
1
star
86

libconfd

mini confd lib, based on confd/memkv/secconf/logger
Go
1
star
87

wat-go

wat-go: WebAssemblyๆ–‡ๆœฌๆ ผๅผๅทฅๅ…ท
Go
1
star
88

static-public

้™ๆ€ๆ•ฐๆฎ๏ผŒไปฅgithub-pagesๅ‘ๅธƒ
JavaScript
1
star