44 lines
957 B
Go
44 lines
957 B
Go
package commands
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
// Pre-renders thumbnails
|
|
var ThumbnailsCommand = cli.Command{
|
|
Name: "thumbnails",
|
|
Usage: "Render default thumbnails",
|
|
Flags: []cli.Flag{
|
|
cli.BoolFlag{
|
|
Name: "force, f",
|
|
Usage: "Re-create existing thumbnails",
|
|
},
|
|
},
|
|
Action: thumbnailsAction,
|
|
}
|
|
|
|
func thumbnailsAction(ctx *cli.Context) error {
|
|
conf := config.NewConfig(ctx)
|
|
|
|
if err := conf.CreateDirectories(); err != nil {
|
|
return err
|
|
}
|
|
|
|
log.Infof("creating default thumbnails in \"%s\"", conf.ThumbnailsPath())
|
|
start := time.Now()
|
|
|
|
if err := photoprism.CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.ThumbnailsPath(), ctx.Bool("force")); err != nil {
|
|
log.Error(err)
|
|
return err
|
|
}
|
|
|
|
log.Infof("default thumbnails created in %s", time.Since(start))
|
|
|
|
return nil
|
|
}
|