https://github.com/joway/libimagequant-go
golang wrapper for libimagequant.
https://github.com/joway/libimagequant-go
compression golang libimagequant png
Last synced: about 1 year ago
JSON representation
golang wrapper for libimagequant.
- Host: GitHub
- URL: https://github.com/joway/libimagequant-go
- Owner: joway
- License: mit
- Created: 2019-01-09T16:09:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-09T11:00:01.000Z (about 7 years ago)
- Last Synced: 2025-03-25T07:51:09.357Z (about 1 year ago)
- Topics: compression, golang, libimagequant, png
- Language: C
- Homepage:
- Size: 745 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libimagequant-go

[](https://goreportcard.com/report/github.com/joway/libimagequant-go)
[](https://codecov.io/gh/joway/libimagequant-go)
[](https://circleci.com/gh/joway/libimagequant-go)
A golang wrapper for [libimagequant](https://github.com/ImageOptim/libimagequant).
## Used by
- [imagic](https://github.com/joway/imagic): An easy and fast tool to process images.
## Install
```shell
go get github.com/joway/libimagequant-go
```
## Usage
### High Level API
```
// compress png iamge
func Compress(img image.Image, quality int, speed int) (image.Image, error)
```
### Low Level API
[GoDoc](https://godoc.org/github.com/joway/libimagequant-go/pngquant)
## Example
```golang
package main
import (
"fmt"
"github.com/joway/libimagequant-go/pngquant"
"image/png"
"os"
)
func main() {
source, _ := os.OpenFile("testdata/1.png", os.O_RDONLY, 0444)
img, _ := png.Decode(source)
quality := 70
speed := 5 // 1~10
output, err := pngquant.Compress(img, quality, speed)
}
```