3d990fc3fd
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
28 lines
570 B
Go
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
|
|
}
|