photoprism/internal/frame/polaroid.go
Michael Mayer a30cbb19b7 Albums: Regenerate share preview after one hour and after changes #3658
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-09-08 17:36:56 +02:00

33 lines
677 B
Go

package frame
import (
"bytes"
_ "embed"
"image"
"image/color"
"github.com/disintegration/imaging"
)
//go:embed polaroid.png
var polaroidPng []byte
// Polaroid embeds the specified image file into a Polaroid frame and returns the resulting image.
func polaroid(img image.Image, rotate float64) (image.Image, error) {
// Create image frame.
frm, err := imaging.Decode(bytes.NewReader(polaroidPng))
if err != nil {
return nil, err
}
// Paste image into frame.
out := imaging.Paste(frm, img, image.Pt(200, 152))
// Rotate image before returning it?
if rotate != 0.0 {
out = imaging.Rotate(out, rotate, color.NRGBA{255, 255, 255, 0})
}
return out, nil
}