scaleImage resizes img to the given dimensions using CatmullRom (bicubic) interpolation.
(img image.Image, w, h int)
| 250 | |
| 251 | // scaleImage resizes img to the given dimensions using CatmullRom (bicubic) interpolation. |
| 252 | func scaleImage(img image.Image, w, h int) image.Image { |
| 253 | dst := image.NewRGBA(image.Rect(0, 0, w, h)) |
| 254 | draw.CatmullRom.Scale(dst, dst.Bounds(), img, img.Bounds(), draw.Over, nil) |
| 255 | return dst |
| 256 | } |
| 257 | |
| 258 | // pickSmallestEncoding encodes the image as both PNG and JPEG and returns whichever is smaller. |
| 259 | func pickSmallestEncoding(img image.Image) ([]byte, string, error) { |