From c1ffd71e25ac1074dc1ff27bb33619c35e7cf6d9 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 2 Jul 2024 02:24:01 -0700 Subject: [PATCH] use resize.Thumbnail mode instead of calculating size --- txt.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/txt.go b/txt.go index 8f57cd3..8695675 100644 --- a/txt.go +++ b/txt.go @@ -194,9 +194,7 @@ func smallGif(src []byte) ([]byte, error) { if err != nil { return nil, fmt.Errorf("image decode problem: %v", err) } - if img.Bounds().Max.X-img.Bounds().Min.X > *txtImgSize { // this should come from the form - img = resize.Resize(uint(*txtImgSize), 0, img, resize.NearestNeighbor) - } + img = resize.Thumbnail(uint(*txtImgSize), uint(*txtImgSize), img, resize.NearestNeighbor) var gifBuf bytes.Buffer err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{}) if err != nil {