imagequant

package module
v0.0.0-...-cc794d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

README

go-imagequant

Optimize image size on Go with libimagequant using Go-native image.Image types.

Example

package main

import (
	"image/png"
	"os"

	"github.com/WKBae/go-imagequant"
)

func main() {
	input, _ := os.Open("input.png")
	defer input.Close()
	srcImg, _ := png.Decode(input)
	resImg, _ := imagequant.Quantize(srcImg, &imagequant.Options{
		MinQuality:     0,
		MaxQuality:     100,
		Speed:          5,
		DitheringLevel: 0.5,
		Gamma:          0,
	})
	output, _ := os.OpenFile("output.png", os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0644)
	defer output.Close()
	_ = png.Encode(output, resImg)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Quantize

func Quantize(img image.Image, opts *Options) (*image.Paletted, error)

Types

type Options

type Options struct {
	MinQuality     int
	MaxQuality     int
	Speed          int
	DitheringLevel float32
	Gamma          float64
}

Directories

Path Synopsis
internal
cgo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL