photoprism/internal/commands/import.go

42 lines
967 B
Go
Raw Normal View History

package commands
import (
"github.com/photoprism/photoprism/internal/context"
"github.com/photoprism/photoprism/internal/photoprism"
2019-05-02 14:10:05 +02:00
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
// Imports photos from path defined in command-line args
var ImportCommand = cli.Command{
Name: "import",
Usage: "Imports photos",
Action: importAction,
}
func importAction(ctx *cli.Context) error {
app := context.NewContext(ctx)
if err := app.CreateDirectories(); err != nil {
return err
}
app.MigrateDb()
log.Infof("importing photos from %s", app.ImportPath())
tensorFlow := photoprism.NewTensorFlow(app.TensorFlowModelPath())
indexer := photoprism.NewIndexer(app.OriginalsPath(), tensorFlow, app.Db())
converter := photoprism.NewConverter(app.DarktableCli())
importer := photoprism.NewImporter(app.OriginalsPath(), indexer, converter)
importer.ImportPhotosFromDirectory(app.ImportPath())
2019-05-02 14:10:05 +02:00
log.Info("photo import complete")
return nil
}