diff --git a/go.mod b/go.mod index 2866a79..abdf4f6 100644 --- a/go.mod +++ b/go.mod @@ -9,10 +9,10 @@ require ( github.com/PurpleSec/escape v1.0.0 github.com/RyanCarrier/dijkstra/v2 v2.0.2 github.com/ansrivas/fiberprometheus/v2 v2.6.1 + github.com/bamiaux/rez v0.0.0-20170731184118-29f4463c688b github.com/cockroachdb/pebble v1.1.1 github.com/gofiber/fiber/v2 v2.52.4 github.com/kelindar/binary v1.0.19 - github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/rs/zerolog v1.33.0 github.com/tdewolff/parse/v2 v2.7.15 github.com/tidwall/gjson v1.17.1 diff --git a/go.sum b/go.sum index 97f9e25..c901428 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsVi github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= github.com/ansrivas/fiberprometheus/v2 v2.6.1 h1:wac3pXaE6BYYTF04AC6K0ktk6vCD+MnDOJZ3SK66kXM= github.com/ansrivas/fiberprometheus/v2 v2.6.1/go.mod h1:MloIKvy4yN6hVqlRpJ/jDiR244YnWJaQC0FIqS8A+MY= +github.com/bamiaux/rez v0.0.0-20170731184118-29f4463c688b h1:5Ci5wpOL75rYF6RQGRoqhEAU6xLJ6n/D4SckXX1yB74= +github.com/bamiaux/rez v0.0.0-20170731184118-29f4463c688b/go.mod h1:obBQGGIFbbv9KWg92Qu9UHeD94JXmHD1jovY/z6I3O8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -69,8 +71,6 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= -github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= diff --git a/handlers/grid.go b/handlers/grid.go index ff25723..62ca81f 100644 --- a/handlers/grid.go +++ b/handlers/grid.go @@ -16,8 +16,8 @@ import ( scraper "instafix/handlers/scraper" "github.com/RyanCarrier/dijkstra/v2" + "github.com/bamiaux/rez" "github.com/gofiber/fiber/v2" - "github.com/nfnt/resize" ) var transport = &http.Transport{ @@ -119,8 +119,12 @@ func GenerateGrid(images []image.Image) (image.Image, error) { oldImWidth := 0 for _, imageOne := range inRow { newWidth := float64(heightRows[i-1]) * float64(imageOne.Bounds().Dx()) / float64(imageOne.Bounds().Dy()) - imageOne = resize.Resize(uint(newWidth), uint(heightRows[i-1]), imageOne, resize.MitchellNetravali) - draw.Draw(canvas, image.Rect(oldImWidth, oldRowHeight, oldImWidth+imageOne.Bounds().Dx(), oldRowHeight+imageOne.Bounds().Dy()), imageOne, imageOne.Bounds().Min, draw.Src) + newImage := image.NewYCbCr(image.Rect(0, 0, int(newWidth), int(heightRows[i-1])), image.YCbCrSubsampleRatio420) + // imageOne = resize.Resize(uint(newWidth), uint(heightRows[i-1]), imageOne, resize.MitchellNetravali) + if err := rez.Convert(newImage, imageOne, rez.NewBicubicFilter()); err != nil { + return nil, err + } + draw.Draw(canvas, image.Rect(oldImWidth, oldRowHeight, oldImWidth+newImage.Bounds().Dx(), oldRowHeight+newImage.Bounds().Dy()), newImage, newImage.Bounds().Min, draw.Src) oldImWidth += int(newWidth) } oldRowHeight += heightRows[i-1]