Moved image resize functionality into image_manip

This commit is contained in:
Samuel Hawksby-Robinson 2020-09-18 15:51:53 +01:00
parent 444a435402
commit 3745d24321
No known key found for this signature in database
GPG Key ID: 64CF99D4A64A1205
3 changed files with 9 additions and 7 deletions

View File

@ -1,10 +1,12 @@
package main
import (
"github.com/oliamb/cutter"
"image"
"image/draw"
"log"
"github.com/nfnt/resize"
"github.com/oliamb/cutter"
)
func cropImage(img image.Image) image.Image {
@ -27,6 +29,10 @@ func cropImage(img image.Image) image.Image {
return croppedImg
}
func resizeSquareImage(size uint, img image.Image) image.Image {
return resize.Resize(size, 0, img, resize.Bilinear)
}
func circleCropImage(img image.Image, size int) image.Image {
dst := image.NewRGBA(image.Rect(0, 0, size, size))
draw.DrawMask(

View File

@ -1,9 +1,5 @@
package main
import (
"github.com/nfnt/resize"
)
var (
images = []string{
"elephant",
@ -33,7 +29,7 @@ func main() {
for _, size := range sizes {
for i := 1; i < 11; i++ {
ri := resize.Resize(size, 0, croppedImg, resize.Bilinear)
ri := resizeSquareImage(size, croppedImg)
id := makeImageDetails(imageName, size, i*10, "")
outputImage(ri, &id)
imgDs[imageName] = append(imgDs[imageName], id)