This commit is contained in:
2025-04-21 23:05:42 -04:00
parent 4ff0c534c6
commit a05558351f
2 changed files with 53 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package resize
import (
"bytes"
"fmt"
"github.com/nfnt/resize"
i "image"
"image/jpeg"
@@ -9,6 +10,10 @@ import (
)
func Shrink(image string, maxSize uint, quality int) (string, error) {
if quality < 1 || quality > 100 {
return "", fmt.Errorf("quality must be between 1 and 100, got %d", quality)
}
img, _, err := i.Decode(bytes.NewReader([]byte(image)))
if err != nil {
return "", err