imageutil

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FitSize

func FitSize(w, h, side int) (int, int, bool)

Width and height of a w by h image scaled down to fit inside a side by side box with its aspect ratio kept and neither below one; the size unchanged and false when it already fits

func Quantize

func Quantize(img *image.NRGBA, colors int) *image.Paletted

Palette image of img with at most colors opaque entries, colors held to 1 through 256, found by cutting its colour space again and again where the cut leaves the least squared error, each pixel weighted by its opacity; every pixel, clear ones included, takes the entry nearest its colour

func Resize

func Resize(img *image.NRGBA, w, h int, filter Filter) *image.NRGBA

Copy of img scaled to w by h with the filter, colours weighted by their alpha so transparent pixels never bleed into visible ones; an empty image for a size that is not positive and a clear one when img has no pixels

func Thumbnail

func Thumbnail(img *image.NRGBA, side int, filter Filter) *image.NRGBA

Copy of img scaled down with the filter to fit inside a side by side box with its aspect ratio kept, a plain copy when it already fits

func ToNRGBA

func ToNRGBA(src image.Image) *image.NRGBA

Straight alpha RGBA copy of any image with its top left corner moved to the origin

Types

type Filter

type Filter int

Resampling kernel Resize and Thumbnail scale with

const (
	// Three lobe windowed sinc, the sharpest result for photos and artwork scaled either way
	Lanczos Filter = iota
	// Cubic spline with a of minus one half, a little softer than Lanczos with less ringing at hard edges
	CatmullRom
	// Nearest source pixel, keeping hard edges and exact colours for palette images and pixel art
	Nearest
)

Jump to

Keyboard shortcuts

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