Implemented convert command

This commit is contained in:
Michael Mayer 2018-06-16 14:19:18 +02:00
parent c04d33da58
commit 187449226a
4 changed files with 75 additions and 18 deletions

8
Gopkg.lock generated
View file

@ -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

View file

@ -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.")

View file

@ -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

View file

@ -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: