From 866750700bcdb7a4b36a43a4700041c04b41f271 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 2 Jul 2024 01:05:07 -0700 Subject: [PATCH] only resize larger images --- txt.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/txt.go b/txt.go index 58b8550..6b59807 100644 --- a/txt.go +++ b/txt.go @@ -196,9 +196,11 @@ func smallGif(src []byte) ([]byte, error) { if err != nil { return nil, fmt.Errorf("image decode problem: %v", err) } - sm := resize.Resize(200, 0, img, resize.NearestNeighbor) + if img.Bounds().Max.X-img.Bounds().Min.X > 200 { + img = resize.Resize(200, 0, img, resize.NearestNeighbor) + } var gifBuf bytes.Buffer - err = gif.Encode(&gifBuf, gifPalette(sm, 216), &gif.Options{}) + err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{}) if err != nil { return nil, fmt.Errorf("gif encode problem: %v", err) }