2018-09-24 09:53:16 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-10-31 07:14:33 +01:00
|
|
|
"log"
|
|
|
|
|
2018-09-24 09:53:16 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ConvertCommand = cli.Command{
|
|
|
|
Name: "convert",
|
|
|
|
Usage: "Converts RAW originals to JPEG",
|
|
|
|
Action: convertAction,
|
|
|
|
}
|
|
|
|
|
2018-10-31 02:42:54 +01:00
|
|
|
// Converts images to JPEG; called by ConvertCommand
|
2018-09-24 09:53:16 +02:00
|
|
|
func convertAction(context *cli.Context) error {
|
|
|
|
conf := photoprism.NewConfig(context)
|
|
|
|
|
|
|
|
if err := conf.CreateDirectories(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|