mirror of
https://github.com/Damillora/Shioriko.git
synced 2025-02-23 09:23:38 +00:00
feat: add preview URL to upload blob for preview
This commit is contained in:
parent
7bb7a3389b
commit
3d40add1b2
@ -11,8 +11,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
_ "golang.org/x/image/webp"
|
|
||||||
"golang.org/x/image/draw"
|
"golang.org/x/image/draw"
|
||||||
|
_ "golang.org/x/image/webp"
|
||||||
|
|
||||||
"github.com/Damillora/Shioriko/pkg/config"
|
"github.com/Damillora/Shioriko/pkg/config"
|
||||||
"github.com/Damillora/Shioriko/pkg/database"
|
"github.com/Damillora/Shioriko/pkg/database"
|
||||||
@ -130,13 +130,13 @@ func uploadBlob(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resize logic
|
// Resize logic
|
||||||
previewWidth := 1000;
|
previewWidth := 1000
|
||||||
previewFactor := float32(previewWidth) / float32(width)
|
previewFactor := float32(previewWidth) / float32(width)
|
||||||
previewHeight := int(float32(height) * previewFactor)
|
previewHeight := int(float32(height) * previewFactor)
|
||||||
if width <= previewWidth {
|
if width <= previewWidth {
|
||||||
previewHeight = height
|
previewHeight = height
|
||||||
}
|
}
|
||||||
thumbnailWidth := 300;
|
thumbnailWidth := 300
|
||||||
thumbnailFactor := float32(thumbnailWidth) / float32(width)
|
thumbnailFactor := float32(thumbnailWidth) / float32(width)
|
||||||
thumbnailHeight := int(float32(height) * thumbnailFactor)
|
thumbnailHeight := int(float32(height) * thumbnailFactor)
|
||||||
if width <= thumbnailWidth {
|
if width <= thumbnailWidth {
|
||||||
@ -201,6 +201,7 @@ func uploadBlob(c *gin.Context) {
|
|||||||
ID: id,
|
ID: id,
|
||||||
Width: width,
|
Width: width,
|
||||||
Height: height,
|
Height: height,
|
||||||
|
PreviewUrl: "/data/" + blob.PreviewFilePath,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ type BlobResponse struct {
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
Height int `json:"height"`
|
Height int `json:"height"`
|
||||||
|
PreviewUrl string `json:"previewUrl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlobSimilarResponse struct {
|
type BlobSimilarResponse struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user