Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change thumbnail default size and resize algorithm #336

Merged
merged 4 commits into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/api/resolver_query_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ func (r *queryResolver) Logs(ctx context.Context) ([]*models.LogEntry, error) {
}

return ret, nil
}
}
11 changes: 9 additions & 2 deletions pkg/api/routes_gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var once sync.Once
type flagStruct struct {
configFilePath string
}

var flags = flagStruct{}

func GetInstance() *singleton {
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/running_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var (
streamingFiles = make(map[string][]*http.ResponseWriter)
streamingFiles = make(map[string][]*http.ResponseWriter)
streamingFilesMutex = sync.RWMutex{}
)

Expand Down
10 changes: 5 additions & 5 deletions pkg/manager/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"strconv"

"github.com/jmoiron/sqlx"

"github.com/stashapp/stash/pkg/logger"
"github.com/stashapp/stash/pkg/models"
"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()

_, err := qb.Find(sceneID)
if err != nil {
return err
Expand All @@ -40,7 +40,7 @@ func DestroyScene(sceneID int, tx *sqlx.Tx) (error) {
if err := qb.Destroy(strconv.Itoa(sceneID), tx); err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -130,4 +130,4 @@ func DeleteSceneFile(scene *models.Scene) {
if err != nil {
logger.Warnf("Could not delete file %s: %s", scene.Path, err.Error())
}
}
}
1 change: 1 addition & 0 deletions pkg/manager/task_autotag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const testExtension = ".mp4"
const existingStudioName = "ExistingStudio"

const existingStudioSceneName = testName + ".dontChangeStudio" + testExtension

var existingStudioID int

var testSeparators = []string{
Expand Down
4 changes: 2 additions & 2 deletions pkg/models/model_gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions pkg/models/querybuilder_scene_marker.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
havingClauses = append(havingClauses, "((COUNT(DISTINCT ptj.id) + COUNT(DISTINCT tj.tag_id)) >= "+strconv.Itoa(requiredCount)+")")
} else if tagsFilter.Modifier == CriterionModifierExcludes {
// excludes all of the provided ids
whereClauses = append(whereClauses, "scene_markers.primary_tag_id not in " + getInBinding(length))
whereClauses = append(whereClauses, "not exists (select smt.scene_marker_id from scene_markers_tags as smt where smt.scene_marker_id = scene_markers.id and smt.tag_id in " + getInBinding(length) + ")")
whereClauses = append(whereClauses, "scene_markers.primary_tag_id not in "+getInBinding(length))
whereClauses = append(whereClauses, "not exists (select smt.scene_marker_id from scene_markers_tags as smt where smt.scene_marker_id = scene_markers.id and smt.tag_id in "+getInBinding(length)+")")
}

for _, tagID := range tagsFilter.Value {
Expand All @@ -176,7 +176,7 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp

if sceneTagsFilter := sceneMarkerFilter.SceneTags; sceneTagsFilter != nil && len(sceneTagsFilter.Value) > 0 {
length := len(sceneTagsFilter.Value)

if sceneTagsFilter.Modifier == CriterionModifierIncludes || sceneTagsFilter.Modifier == CriterionModifierIncludesAll {
body += " LEFT JOIN scenes_tags AS scene_tags_join ON scene_tags_join.scene_id = scene.id AND scene_tags_join.tag_id IN " + getInBinding(length)

Expand All @@ -191,9 +191,9 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
havingClauses = append(havingClauses, "COUNT(DISTINCT scene_tags_join.tag_id) >= "+strconv.Itoa(requiredCount))
} else if sceneTagsFilter.Modifier == CriterionModifierExcludes {
// excludes all of the provided ids
whereClauses = append(whereClauses, "not exists (select st.scene_id from scenes_tags as st where st.scene_id = scene.id AND st.tag_id IN " + getInBinding(length) + ")")
whereClauses = append(whereClauses, "not exists (select st.scene_id from scenes_tags as st where st.scene_id = scene.id AND st.tag_id IN "+getInBinding(length)+")")
}

for _, tagID := range sceneTagsFilter.Value {
args = append(args, tagID)
}
Expand All @@ -213,13 +213,13 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
if performersFilter.Modifier == CriterionModifierIncludesAll {
requiredCount = length
}

havingClauses = append(havingClauses, "COUNT(DISTINCT scene_performers.performer_id) >= "+strconv.Itoa(requiredCount))
} else if performersFilter.Modifier == CriterionModifierExcludes {
// excludes all of the provided ids
whereClauses = append(whereClauses, "not exists (select sp.scene_id from performers_scenes as sp where sp.scene_id = scene.id AND sp.performer_id IN " + getInBinding(length) + ")")
whereClauses = append(whereClauses, "not exists (select sp.scene_id from performers_scenes as sp where sp.scene_id = scene.id AND sp.performer_id IN "+getInBinding(length)+")")
}

for _, performerID := range performersFilter.Value {
args = append(args, performerID)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/resources.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package utils

var PendingGenerateResource, _ = GetDataFromBase64String("iVBORw0KGgoAAAANSUhEUgAAAfQAAADwBAMAAAAEHosbAAAAG1BMVEUAAADMzMyZmZkzMzNmZmZ/f38ZGRmysrJMTEwh+DPkAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEOklEQVR4nO3YzW/bNhjHcfpN9jGP8iIfI2xrdrQLrLs67Zpdo21pelTWdbnGSTPvaBdosT+7z8OXxAFkIDu0Vrfv59AmpEjoJ1IkFecAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMC/JCqfNNV0Dja1GR0Vv36+O/piLLrsNdVo9EyaKnpzbfLkMZ1vfnptIGdnZ6XUDTUbo0+lOJKiqUlDFy1mqbP5aUPNpujZfK92b6WpSUMXLeYHfHXVULPpvvtiS0P1mFRfQfSLnYaaTffd8SvDsHF9eGQX7eCj2y2+n79z9hCeFq/0/7fzJ2HCp4LsPJ+EJWHln1P/1vmlfqZV0itvrSp0IX9WS9c/yk9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WXkr8O73oqbaEYvRsPZzGplT4YdXvX46iHU+8ovuvOpeipC7uquvFdpXe9nWL0gW29b+qU1Ja56Xr0gSbohWtt4QvLvR1usmcpeurCrrKXIox6Km2hGL2v27eNYkxqk/p4PbrVD8K1A/+9apu87tw2qjF66sIvevrojndSw7VTUJvE6OHkMUlJp3ouna9Ht/ppuDaTGzvI2fnHjjS7KXrqwo/6TOfIji2OqbSF0kGrysNBNr7a+eSprEfX+pcSr13J7S8yLmudBt+Gg2zoJ3bh3/X9fyr9rB/mH1NpC6Xo3fj5EgdZt+wHE97q9+K1I9uullXtTzb53TKXuggrvBSXMhvo50u3rXvbXXT3vvje3UXXj9a/H2xuzv1cfEzX/jEvTtxKfxmV18v76LGLsK8Xs95imZU3qfTr1vyXuv+83gsd42Lbd7EVI/tyy7d9F1uRyateOd72XWyHfaY2/d32f8C2q1YeTD6/7Pn1ybbvAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAL+ITrOa6fKadMcEAAAAASUVORK5CYII=")
2 changes: 1 addition & 1 deletion tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ package main

import (
_ "github.com/99designs/gqlgen"
)
)