summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandomChars <random@chars.jp>2021-10-09 12:51:19 +0900
committerRandomChars <random@chars.jp>2021-10-09 12:51:19 +0900
commit61c52917b75dcd9195bb16186015af97c2f5ec7c (patch)
treed96a5d662570182812da266eb47a7b2f66f37cd6
parent1a987c9e04109505681b4ae0d6b7700d8b3b6f13 (diff)
export MakePreviewv1.4.0
-rw-r--r--store/image.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/store/image.go b/store/image.go
index c136916..95b5c1d 100644
--- a/store/image.go
+++ b/store/image.go
@@ -29,6 +29,11 @@ type Image struct {
CommentaryTranslation string `json:"commentary_translation"`
}
+// MakePreview compresses an image.Image to preview-size.
+func MakePreview(img image.Image) image.Image {
+ return resize.Thumbnail(256, 256, img, resize.Bilinear)
+}
+
// Images returns a slice of image hashes.
func (s *Store) Images() []string {
var images []string
@@ -236,7 +241,7 @@ func (s *Store) ImageAdd(data []byte, flake string) Image {
log.Warnf("Error decoding upload %s, %s", info.Hash, err)
return Image{}
} else {
- img = resize.Thumbnail(256, 256, i, resize.Bilinear)
+ img = MakePreview(i)
info.Type = format
}