Documentation ¶
Overview ¶
Package resize implements various image resizing methods.
The package works with the Image interface described in the image package. Various interpolation methods are provided and multiple processors may be utilized in the computations.
Example:
imgResized := resize.Resize(1000, 0, imgOld, resize.MitchellNetravali)
Index ¶
- func Resize(width, height uint, img image.Image, interp InterpolationFunction) image.Image
- func ResizeReader(width, height uint, rd io.Reader, blur float64, interp InterpolationFunction) (img image.Image, format string, err error)
- func ResizeWithBlur(width, height uint, img image.Image, blur float64, ...) image.Image
- func Thumbnail(maxWidth, maxHeight uint, img image.Image, interp InterpolationFunction) image.Image
- type InterpolationFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Resize ¶
Resize scales an image to new width and height using the interpolation function interp. A new image with the given dimensions will be returned. If one of the parameters width or height is set to 0, its size will be calculated so that the aspect ratio is that of the originating image. The resizing algorithm uses channels for parallel computation. If the input image has width or height of 0, it is returned unchanged.
func ResizeReader ¶ added in v1.0.1
func ResizeReader(width, height uint, rd io.Reader, blur float64, interp InterpolationFunction) (img image.Image, format string, err error)
ResizeReader decodes an image from a reader and calls Resize with the given params. Supported formats are: PNG, JPEG, GIF by default. To support other formats, import the package that implements the format.
func ResizeWithBlur ¶ added in v1.0.1
func ResizeWithBlur(width, height uint, img image.Image, blur float64, interp InterpolationFunction) image.Image
ResizeWithBlur scales an image to new width and height using the interpolation function interp and given blur factor. A new image with the given dimensions will be returned. If one of the parameters width or height is set to 0, its size will be calculated so that the aspect ratio is that of the originating image. The resizing algorithm uses channels for parallel computation. If the input image has width or height of 0, it is returned unchanged.
Types ¶
type InterpolationFunction ¶
type InterpolationFunction int
An InterpolationFunction provides the parameters that describe an interpolation kernel. It returns the number of samples to take and the kernel function to use for sampling.
const ( // Nearest-neighbor interpolation NearestNeighbor InterpolationFunction = iota // Bilinear interpolation Bilinear // Bicubic interpolation (with cubic hermite spline) Bicubic // Mitchell-Netravali interpolation MitchellNetravali // Lanczos interpolation (a=2) Lanczos2 // Lanczos interpolation (a=3) Lanczos3 )
InterpolationFunction constants