mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Change thumbnail default size and resize algorithm (#336)
* Change thumbnail resize algorithm and add size parameter * Height -> Width * Change default size from 100px to 200px * Height -> width
This commit is contained in:
parent
03c07a429d
commit
6a6e8d8875
10 changed files with 30 additions and 21 deletions
|
|
@ -27,9 +27,16 @@ func (rs galleryRoutes) File(w http.ResponseWriter, r *http.Request) {
|
|||
thumb := r.URL.Query().Get("thumb")
|
||||
w.Header().Add("Cache-Control", "max-age=604800000") // 1 Week
|
||||
if thumb == "true" {
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex))
|
||||
} else {
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex, 200))
|
||||
} else if thumb == "" {
|
||||
_, _ = w.Write(gallery.GetImage(fileIndex))
|
||||
} else {
|
||||
width, err := strconv.ParseInt(thumb, 0, 64)
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(400), 400)
|
||||
return
|
||||
}
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex, int(width)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ var once sync.Once
|
|||
type flagStruct struct {
|
||||
configFilePath string
|
||||
}
|
||||
|
||||
var flags = flagStruct{}
|
||||
|
||||
func GetInstance() *singleton {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/stashapp/stash/pkg/utils"
|
||||
)
|
||||
|
||||
func DestroyScene(sceneID int, tx *sqlx.Tx) (error) {
|
||||
func DestroyScene(sceneID int, tx *sqlx.Tx) error {
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
jqb := models.NewJoinsQueryBuilder()
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const testExtension = ".mp4"
|
|||
const existingStudioName = "ExistingStudio"
|
||||
|
||||
const existingStudioSceneName = testName + ".dontChangeStudio" + testExtension
|
||||
|
||||
var existingStudioID int
|
||||
|
||||
var testSeparators = []string{
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ func (g *Gallery) GetImage(index int) []byte {
|
|||
return data
|
||||
}
|
||||
|
||||
func (g *Gallery) GetThumbnail(index int) []byte {
|
||||
func (g *Gallery) GetThumbnail(index int, width int) []byte {
|
||||
data, _ := g.readZipFile(index)
|
||||
srcImage, _, err := image.Decode(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return data
|
||||
}
|
||||
resizedImage := imaging.Resize(srcImage, 100, 0, imaging.NearestNeighbor)
|
||||
resizedImage := imaging.Resize(srcImage, width, 0, imaging.Box)
|
||||
buf := new(bytes.Buffer)
|
||||
err = jpeg.Encode(buf, resizedImage, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue