Resizing images

suggest change

There are several libraries for resizing images in Go. Package golang.org/x/image/draw is one of the options:

func resize(src image.Image, dstSize image.Point) *image.RGBA {
	srcRect := src.Bounds()
	dstRect := image.Rectangle{
		Min: image.Point{0, 0},
		Max: dstSize,
	}
	dst := image.NewRGBA(dstRect)
	draw.CatmullRom.Scale(dst, dstRect, src, srcRect, draw.Over, nil)
	return dst
}

Notable points:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents