2018-02-04 17:34:07 +01:00
|
|
|
package photoprism
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/disintegration/imaging"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
2018-02-28 10:08:49 +01:00
|
|
|
func CreateThumbnail() {
|
2018-02-04 17:34:07 +01:00
|
|
|
src, err := imaging.Open("testdata/lena_512.png")
|
2018-02-28 10:04:24 +01:00
|
|
|
|
2018-02-04 17:34:07 +01:00
|
|
|
if err != nil {
|
2018-02-28 10:04:24 +01:00
|
|
|
log.Printf("Open failed: %s", err.Error())
|
2018-02-04 17:34:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Crop the original image to 350x350px size using the center anchor.
|
|
|
|
src = imaging.CropAnchor(src, 350, 350, imaging.Center)
|
|
|
|
|
|
|
|
// Resize the cropped image to width = 256px preserving the aspect ratio.
|
|
|
|
src = imaging.Resize(src, 256, 0, imaging.Lanczos)
|
2018-02-28 10:08:49 +01:00
|
|
|
}
|