photoprism/internal/thumb/jpeg.go
Michael Mayer 3d990fc3fd Backend: Add support for PNG, TIFF, BMP and GIF #38 #156
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-01-06 17:50:05 +01:00

28 lines
570 B
Go

package thumb
import (
"image"
"github.com/disintegration/imaging"
)
func Jpeg(srcFilename, jpgFilename string) (result image.Image, err error) {
img, err := imaging.Open(srcFilename, imaging.AutoOrientation(true))
if err != nil {
log.Errorf("thumbs: can't open %s", srcFilename)
return result, err
}
var saveOption imaging.EncodeOption
saveOption = imaging.JPEGQuality(JpegQuality)
err = imaging.Save(img, jpgFilename, saveOption)
if err != nil {
log.Errorf("thumbs: failed to save %s", jpgFilename)
return result, err
}
return result, nil
}