Moved image resize functionality into image_manip
This commit is contained in:
parent
444a435402
commit
3745d24321
|
@ -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(
|
||||
|
|
6
main.go
6
main.go
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue