You've already forked collage-maker
Replace oneofone with imaging for image resize
This commit is contained in:
@ -11,7 +11,6 @@ import (
|
||||
"io/fs"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
"go.oneofone.dev/resize"
|
||||
)
|
||||
|
||||
type Dimension struct {
|
||||
@ -65,13 +64,13 @@ func Make(req *Request, source fs.FS, output io.Writer) error {
|
||||
}
|
||||
|
||||
destRect := FrameTranslate(req.Aspect, req.Dimension, photo.Frame).ToImgRect()
|
||||
resizedImg := resize.Resize(uint(destRect.Dx()), uint(destRect.Dy()), croppedImage, resize.Lanczos3)
|
||||
resizedImg := imaging.Resize(croppedImage, destRect.Dx(), destRect.Dy(), imaging.Lanczos)
|
||||
draw.Draw(canvas, destRect, resizedImg, image.Point{0, 0}, draw.Src)
|
||||
}
|
||||
var opt jpeg.Options
|
||||
opt.Quality = 100
|
||||
|
||||
return jpeg.Encode(output, canvas, &opt)
|
||||
return jpeg.Encode(output, canvas, &jpeg.Options{
|
||||
Quality: 100,
|
||||
})
|
||||
}
|
||||
|
||||
func FrameTranslate(resolution Dimension, frameSize Dimension, frame Rectangle) Rectangle {
|
||||
|
Reference in New Issue
Block a user