feat: show thumbnails in browser listing, fix object actions overflow

This commit is contained in:
2024-10-14 00:14:34 +00:00
parent 37027396ca
commit 1b1b815443
8 changed files with 87 additions and 33 deletions
+26
View File
@@ -0,0 +1,26 @@
package utils
import (
"bytes"
"image"
_ "image/gif"
"image/jpeg"
_ "image/png"
"github.com/nfnt/resize"
)
func CreateThumbnailImage(buffer []byte, width uint, height uint) ([]byte, error) {
img, _, err := image.Decode(bytes.NewReader(buffer))
if err != nil {
return nil, err
}
thumb := resize.Thumbnail(width, height, img, resize.NearestNeighbor)
buf := new(bytes.Buffer)
if err := jpeg.Encode(buf, thumb, nil); err != nil {
return nil, err
}
return buf.Bytes(), nil
}