43 lines
991 B
Go
43 lines
991 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/photoprism/photoprism/internal/context"
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var ImportCommand = cli.Command{
|
|
Name: "import",
|
|
Usage: "Imports photos",
|
|
Action: importAction,
|
|
}
|
|
|
|
// Imports photos from path defined in ctx arg; called by ImportCommand;
|
|
func importAction(ctx *cli.Context) error {
|
|
conf := context.NewConfig(ctx)
|
|
|
|
if err := conf.CreateDirectories(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
conf.MigrateDb()
|
|
|
|
fmt.Printf("Importing photos from %s...\n", conf.GetImportPath())
|
|
|
|
tensorFlow := photoprism.NewTensorFlow(conf.GetTensorFlowModelPath())
|
|
|
|
indexer := photoprism.NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.GetDb())
|
|
|
|
converter := photoprism.NewConverter(conf.GetDarktableCli())
|
|
|
|
importer := photoprism.NewImporter(conf.GetOriginalsPath(), indexer, converter)
|
|
|
|
importer.ImportPhotosFromDirectory(conf.GetImportPath())
|
|
|
|
fmt.Println("Done.")
|
|
|
|
return nil
|
|
}
|