Backend: Fix RAW to JPEG conversion with Sips (OS X)

This commit is contained in:
Michael Mayer 2020-02-01 22:48:07 +01:00
parent d923746abb
commit c02b7ed65b
2 changed files with 10 additions and 3 deletions

View file

@ -91,7 +91,7 @@ func (c *Convert) Start(path string) error {
func (c *Convert) ConvertCommand(image *MediaFile, jpegName string, xmpName string) (result *exec.Cmd, err error) {
if image.IsRaw() {
if c.conf.SipsBin() != "" {
result = exec.Command(c.conf.SipsBin(), "-s format jpeg", image.fileName, "--out "+jpegName)
result = exec.Command(c.conf.SipsBin(), "-s", "format", "jpeg", "--out", jpegName, image.fileName)
} else if c.conf.DarktableBin() != "" {
if xmpName != "" {
result = exec.Command(c.conf.DarktableBin(), image.fileName, xmpName, jpegName)
@ -184,7 +184,11 @@ func (c *Convert) ToJpeg(image *MediaFile) (*MediaFile, error) {
// Run convert command.
if err := cmd.Run(); err != nil {
return nil, errors.New(stderr.String())
if stderr.String() != "" {
return nil, errors.New(stderr.String())
} else {
return nil, err
}
}
return NewMediaFile(jpegName)

View file

@ -1,5 +1,7 @@
package photoprism
import "strings"
type ConvertJob struct {
image *MediaFile
convert *Convert
@ -8,7 +10,8 @@ type ConvertJob struct {
func convertWorker(jobs <-chan ConvertJob) {
for job := range jobs {
if _, err := job.convert.ToJpeg(job.image); err != nil {
log.Warnf("convert: %s (%s)", err.Error(), job.image.FileName())
fileName := job.image.RelativeName(job.convert.conf.OriginalsPath())
log.Errorf("convert: could not create jpeg for %s (%s)", fileName, strings.TrimSpace(err.Error()))
}
}
}