imagequant

package module
v0.0.0-...-76094ff Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: GPL-3.0, HPND, ISC Imports: 5 Imported by: 6

README

imagequant

This library was taken from https://code.ivysaur.me/go-imagequant/.

The only code changes made are

  • Change import paths to github.com/1lann/imagequant.
  • Use []byte as NewImage's rgba32data argument instead of string.
  • GoImageToRgba32 and Rgb8PaletteToGoImage are taken from cmd/gopngquant/main.go and replicated in Image.go such that it's available in the package.
  • Uses imagequant-sys from https://github.com/ImageOptim/libimagequant

Documentation

Index

Constants

View Source
const (
	COLORS_MIN = 2
	COLORS_MAX = 256
)
View Source
const (
	QUALITY_MIN = 0
	QUALITY_MAX = 100
)
View Source
const (
	SPEED_SLOWEST = 1
	SPEED_DEFAULT = 3
	SPEED_FASTEST = 10
)

Variables

View Source
var (
	ErrQualityTooLow      = errors.New("Quality too low")
	ErrValueOutOfRange    = errors.New("Value out of range")
	ErrOutOfMemory        = errors.New("Out of memory")
	ErrAborted            = errors.New("Aborted")
	ErrBitmapNotAvailable = errors.New("Bitmap not available")
	ErrBufferTooSmall     = errors.New("Buffer too small")
	ErrInvalidPointer     = errors.New("Invalid pointer")

	ErrUseAfterFree = errors.New("Use after free")
)

Functions

func GetLibraryVersion

func GetLibraryVersion() int

func GetLibraryVersionString

func GetLibraryVersionString() string

func GoImageToRgba32

func GoImageToRgba32(im image.Image) []byte

func License

func License() string

Returns the license of libimagequant (GPLv3).

func Rgb8PaletteToGoImage

func Rgb8PaletteToGoImage(w, h int, rgb8data []byte, pal color.Palette) image.Image

Types

type Attributes

type Attributes struct {
	// contains filtered or unexported fields
}

func NewAttributes

func NewAttributes() (*Attributes, error)

Callers MUST call Release() on the returned object to free memory.

func (*Attributes) CreateHistogram

func (this *Attributes) CreateHistogram() *Histogram

func (*Attributes) GetMaxColors

func (this *Attributes) GetMaxColors() int

func (*Attributes) GetMaxQuality

func (this *Attributes) GetMaxQuality() int

func (*Attributes) GetMinOpacity

func (this *Attributes) GetMinOpacity() int

func (*Attributes) GetMinPosterization

func (this *Attributes) GetMinPosterization() int

func (*Attributes) GetMinQuality

func (this *Attributes) GetMinQuality() int

func (*Attributes) GetSpeed

func (this *Attributes) GetSpeed() int

func (*Attributes) Release

func (this *Attributes) Release()

Free memory. Callers must not use this object after Release has been called.

func (*Attributes) SetLastIndexTransparent

func (this *Attributes) SetLastIndexTransparent(is_last int)

func (*Attributes) SetMaxColors

func (this *Attributes) SetMaxColors(colors int) error

func (*Attributes) SetMinOpacity

func (this *Attributes) SetMinOpacity(min int) error

func (*Attributes) SetMinPosterization

func (this *Attributes) SetMinPosterization(bits int) error

func (*Attributes) SetQuality

func (this *Attributes) SetQuality(minimum, maximum int) error

func (*Attributes) SetSpeed

func (this *Attributes) SetSpeed(speed int) error

type Histogram

type Histogram struct {
	// contains filtered or unexported fields
}

func (*Histogram) AddImage

func (this *Histogram) AddImage(attr *Attributes, img *Image) error

func (*Histogram) Quantize

func (this *Histogram) Quantize(attr *Attributes) (*Result, error)

func (*Histogram) Release

func (this *Histogram) Release()

Free memory. Callers must not use this object after Release has been called.

type Image

type Image struct {
	// contains filtered or unexported fields
}

func NewImage

func NewImage(attr *Attributes, rgba32data []byte, width, height int, gamma float64) (*Image, error)

Callers MUST call Release() on the returned object to free memory.

func (*Image) Quantize

func (this *Image) Quantize(attr *Attributes) (*Result, error)

func (*Image) Release

func (this *Image) Release()

Free memory. Callers must not use this object after Release has been called.

type Result

type Result struct {
	// contains filtered or unexported fields
}

Callers must not use this object once Release has been called on the parent Image struct.

func (*Result) GetImageHeight

func (this *Result) GetImageHeight() int

func (*Result) GetImageWidth

func (this *Result) GetImageWidth() int

func (*Result) GetOutputGamma

func (this *Result) GetOutputGamma() float64

func (*Result) GetPalette

func (this *Result) GetPalette() color.Palette

func (*Result) GetQuantizationError

func (this *Result) GetQuantizationError() float64

func (*Result) GetQuantizationQuality

func (this *Result) GetQuantizationQuality() float64

func (*Result) GetRemappingError

func (this *Result) GetRemappingError() float64

func (*Result) GetRemappingQuality

func (this *Result) GetRemappingQuality() float64

func (*Result) Release

func (this *Result) Release()

Free memory. Callers must not use this object after Release has been called.

func (*Result) SetDitheringLevel

func (this *Result) SetDitheringLevel(dither_level float32) error

func (*Result) SetOutputGamma

func (this *Result) SetOutputGamma(gamma float64) error

func (*Result) SetOutputImage

func (this *Result) SetOutputImage(img *Image)

func (*Result) WriteRemappedImage

func (this *Result) WriteRemappedImage() ([]byte, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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