2018-09-24 09:53:16 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-10-31 07:14:33 +01:00
|
|
|
|
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
|
|
|
// Converts RAW files to JPEG images, if no JPEG already exists
|
2018-09-24 09:53:16 +02:00
|
|
|
var ConvertCommand = cli.Command{
|
|
|
|
Name: "convert",
|
|
|
|
Usage: "Converts RAW originals to JPEG",
|
|
|
|
Action: convertAction,
|
|
|
|
}
|
|
|
|
|
2018-11-17 06:21:39 +01:00
|
|
|
func convertAction(ctx *cli.Context) error {
|
|
|
|
conf := context.NewConfig(ctx)
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
if err := conf.CreateDirectories(); err != nil {
|
2019-01-15 14:00:42 +01:00
|
|
|
return err
|
2018-09-24 09:53:16 +02:00
|
|
|
}
|
|
|
|
|
2018-12-21 03:21:21 +01:00
|
|
|
fmt.Printf("Converting RAW images in %s to JPEG...\n", conf.OriginalsPath())
|
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
|
|
|
converter.ConvertAll(conf.OriginalsPath())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
fmt.Println("Done.")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|