mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Improve image scanning performance and thumbnail generation (#1655)
* Improve image scanning performance and thumbnail generation * Add vips-tools to build image * Add option to write generated thumbnails to disk * Fallback to image if thumbnail generation fails Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -35,6 +35,18 @@ func GetSourceImage(i *models.Image) (image.Image, error) {
|
||||
return srcImage, nil
|
||||
}
|
||||
|
||||
func DecodeSourceImage(i *models.Image) (*image.Config, *string, error) {
|
||||
f, err := openSourceImage(i.Path)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
config, format, err := image.DecodeConfig(f)
|
||||
|
||||
return &config, &format, err
|
||||
}
|
||||
|
||||
func CalculateMD5(path string) (string, error) {
|
||||
f, err := openSourceImage(path)
|
||||
if err != nil {
|
||||
@@ -154,15 +166,15 @@ func SetFileDetails(i *models.Image) error {
|
||||
return err
|
||||
}
|
||||
|
||||
src, _ := GetSourceImage(i)
|
||||
config, _, err := DecodeSourceImage(i)
|
||||
|
||||
if src != nil {
|
||||
if err == nil {
|
||||
i.Width = sql.NullInt64{
|
||||
Int64: int64(src.Bounds().Max.X),
|
||||
Int64: int64(config.Width),
|
||||
Valid: true,
|
||||
}
|
||||
i.Height = sql.NullInt64{
|
||||
Int64: int64(src.Bounds().Max.Y),
|
||||
Int64: int64(config.Height),
|
||||
Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user