golang wrapper for libimagequant.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
lib @ a2add48
pngquant
testdata
.gitignore
.gitmodules
LICENSE
Makefile
README.md
dep.sh
go.mod
go.sum

README.md

libimagequant-go

GitHub release Go Report Card codecov CircleCI

A golang wrapper for libimagequant.

Used by

  • imagic: An easy and fast tool to process images.

Install

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

Example

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)
}