2018-09-24 09:53:16 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-10-31 07:14:33 +01:00
|
|
|
"log"
|
|
|
|
|
2018-11-17 06:21:39 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/context"
|
2018-09-24 09:53:16 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
2018-11-17 13:57:19 +01:00
|
|
|
// Imports photos from path defined in command-line args
|
2018-09-24 09:53:16 +02:00
|
|
|
var ImportCommand = cli.Command{
|
|
|
|
Name: "import",
|
|
|
|
Usage: "Imports photos",
|
|
|
|
Action: importAction,
|
|
|
|
}
|
|
|
|
|
2018-11-17 06:21:39 +01:00
|
|
|
func importAction(ctx *cli.Context) error {
|
|
|
|
conf := context.NewConfig(ctx)
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
if err := conf.CreateDirectories(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
conf.MigrateDb()
|
|
|
|
|
2018-12-21 03:21:49 +01:00
|
|
|
fmt.Printf("Importing photos from %s...\n", conf.ImportPath())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2018-12-21 03:25:50 +01:00
|
|
|
tensorFlow := photoprism.NewTensorFlow(conf.TensorFlowModelPath())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2018-12-21 03:21:21 +01:00
|
|
|
indexer := photoprism.NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2018-12-21 03:23:05 +01:00
|
|
|
converter := photoprism.NewConverter(conf.DarktableCli())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2018-12-21 03:21:21 +01:00
|
|
|
importer := photoprism.NewImporter(conf.OriginalsPath(), indexer, converter)
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2018-12-21 03:21:49 +01:00
|
|
|
importer.ImportPhotosFromDirectory(conf.ImportPath())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
fmt.Println("Done.")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|