From 187449226a4f59da4a201711fca8d65d6d7796ba Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sat, 16 Jun 2018 14:19:18 +0200 Subject: [PATCH] Implemented convert command --- Gopkg.lock | 8 +--- cmd/photoprism/photoprism.go | 79 ++++++++++++++++++++++++++++++++---- converter.go | 4 +- docker-compose.yml | 2 +- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index d0356c51e..d677372e9 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -43,12 +43,6 @@ packages = ["yaml"] revision = "08cad365cd28a7fba23bb1e57aa43c5e18ad8bb8" -[[projects]] - branch = "master" - name = "github.com/photoprism/photoprism" - packages = ["."] - revision = "7a6c9464cdef3048cd7558fd11e19bbc290312a3" - [[projects]] name = "github.com/pkg/errors" packages = ["."] @@ -115,6 +109,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "b3174d1366468b5b9de596cebcbf97d941b95ce61cca9c13ca5456379f2f68c2" + inputs-digest = "af3dcd4c923c605a744d0ffad8c1a20ed0ce15fc3bdedb6d73b32be52dba9d23" solver-name = "gps-cdcl" solver-version = 1 diff --git a/cmd/photoprism/photoprism.go b/cmd/photoprism/photoprism.go index db6790c26..10b2f7cfe 100644 --- a/cmd/photoprism/photoprism.go +++ b/cmd/photoprism/photoprism.go @@ -37,12 +37,77 @@ func main() { }, { Name: "import", - Usage: "Imports photo from a directory", + Usage: "Import photos from directory", + Action: func(context *cli.Context) error { + conf.SetValuesFromFile(photoprism.GetExpandedFilename(context.GlobalString("config-file"))) + + conf.SetValuesFromCliContext(context) + + fmt.Printf("Importing photos from %s...\n", conf.ImportPath) + + importer := photoprism.NewImporter(conf.OriginalsPath) + + importer.ImportPhotosFromDirectory(conf.ImportPath) + + fmt.Println("Done.") + + return nil + }, + }, + { + Name: "convert", + Usage: "Convert RAW originals to JPEG", + Action: func(context *cli.Context) error { + conf.SetValuesFromFile(photoprism.GetExpandedFilename(context.GlobalString("config-file"))) + + conf.SetValuesFromCliContext(context) + + fmt.Printf("Converting RAW images in %s to JPEG...\n", conf.OriginalsPath) + + converter := photoprism.NewConverter(conf.DarktableCli) + + converter.ConvertAll(conf.OriginalsPath) + + fmt.Println("Done.") + + return nil + }, + }, + { + Name: "thumbnails", + Usage: "Create thumbnails", + Action: func(context *cli.Context) error { + conf.SetValuesFromFile(photoprism.GetExpandedFilename(context.GlobalString("config-file"))) + + conf.SetValuesFromCliContext(context) + + fmt.Printf("Creating thumbnails in %s...\n", conf.ThumbnailsPath) + + fmt.Println("[TODO]") + + fmt.Println("Done.") + + return nil + }, + }, + { + Name: "export", + Usage: "Export photos as JPEG", Flags: []cli.Flag{ cli.StringFlag{ - Name: "import-directory, d", - Usage: "Import directory", - Value: "~/Pictures/Import", + Name: "from, f", + Usage: "Start date & time", + Value: "yesterday", + }, + cli.StringFlag{ + Name: "to, t", + Usage: "End date & time", + Value: "today", + }, + cli.StringFlag{ + Name: "size, s", + Usage: "Max image size in pixels", + Value: "4096", }, }, Action: func(context *cli.Context) error { @@ -50,11 +115,9 @@ func main() { conf.SetValuesFromCliContext(context) - fmt.Printf("Importing photos from %s\n", conf.ImportPath) + fmt.Printf("Exporting photos to %s...\n", conf.ExportPath) - importer := photoprism.NewImporter(conf.OriginalsPath) - - importer.ImportPhotosFromDirectory(conf.ImportPath) + fmt.Println("[TODO]") fmt.Println("Done.") diff --git a/converter.go b/converter.go index 6882c71cf..69959a611 100644 --- a/converter.go +++ b/converter.go @@ -40,8 +40,6 @@ func (c *Converter) ConvertAll(path string) { return nil } - log.Printf("Converting %s \n", filename) - if _, err := c.ConvertToJpeg(mediaFile); err != nil { log.Print(err.Error()) } @@ -73,6 +71,8 @@ func (c *Converter) ConvertToJpeg(image *MediaFile) (*MediaFile, error) { return NewMediaFile(jpegFilename), nil } + log.Printf("Converting %s to %s \n", image.filename, jpegFilename) + xmpFilename := baseFilename + ".xmp" var convertCommand *exec.Cmd diff --git a/docker-compose.yml b/docker-compose.yml index 3dc83360d..9694ca710 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: image: mysql:latest command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=1024 ports: - - 3306:3306 + - 13306:3306 volumes: - database-data:/var/lib/mysql environment: