Replace oneofone with imaging for image resize

This commit is contained in:
2024-08-09 14:21:45 -04:00
parent 014c180a1e
commit b4d58817a5
4 changed files with 7 additions and 11 deletions

View File

@ -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 {