resize

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

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 6 Imported by: 0

README

imgutils-resize

Resize with aspect ratio preservation

Documentation

Overview

Package resize provides image resizing with various interpolation methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resize

func Resize(src image.Image, opts Options) image.Image

Resize scales an image to the specified dimensions.

func ResizeExact

func ResizeExact(src image.Image, width, height int) image.Image

ResizeExact resizes an image to exact dimensions, ignoring aspect ratio.

func ResizeFromFile

func ResizeFromFile(path string, opts Options) (image.Image, error)

ResizeFromFile reads an image file and resizes it.

func ResizeToFit

func ResizeToFit(src image.Image, maxWidth, maxHeight int) image.Image

ResizeToFit resizes an image to fit within the specified dimensions, maintaining aspect ratio.

func ResizeToHeight

func ResizeToHeight(src image.Image, height int) image.Image

ResizeToHeight resizes an image to a specific height, maintaining aspect ratio.

func ResizeToWidth

func ResizeToWidth(src image.Image, width int) image.Image

ResizeToWidth resizes an image to a specific width, maintaining aspect ratio.

func SaveJPEG

func SaveJPEG(img image.Image, w io.Writer, quality int) error

SaveJPEG saves the resized image as JPEG.

func SavePNG

func SavePNG(img image.Image, w io.Writer) error

SavePNG saves the resized image as PNG.

Types

type Interpolation

type Interpolation int

Interpolation defines the resizing algorithm to use.

const (
	// NearestNeighbor is fastest but lowest quality.
	NearestNeighbor Interpolation = iota
	// Bilinear provides decent quality with good performance.
	Bilinear
	// CatmullRom provides high quality results.
	CatmullRom
)

type Options

type Options struct {
	Width         int
	Height        int
	Interpolation Interpolation
	MaintainRatio bool
}

Options configures the resize operation.

Jump to

Keyboard shortcuts

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