Check PHOTOPRISM_JPEG_HIDDEN flag when converting #311
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
4f4e19bd89
commit
f720ca6664
4 changed files with 40 additions and 5 deletions
|
@ -28,7 +28,7 @@ func TestConvert_ToJpeg(t *testing.T) {
|
|||
|
||||
t.Run("gopher-video.mp4", func(t *testing.T) {
|
||||
fileName := conf.ExamplesPath() + "/gopher-video.mp4"
|
||||
outputName := conf.ExamplesPath() + "/.photoprism/gopher-video.jpg"
|
||||
outputName := conf.ExamplesPath() + "/gopher-video.jpg"
|
||||
|
||||
_ = os.Remove(outputName)
|
||||
|
||||
|
@ -40,7 +40,7 @@ func TestConvert_ToJpeg(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
jpegFile, err := convert.ToJpeg(mf, true)
|
||||
jpegFile, err := convert.ToJpeg(mf, false)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -158,6 +158,41 @@ func TestConvert_ToJson(t *testing.T) {
|
|||
_ = os.Remove(outputName)
|
||||
})
|
||||
|
||||
t.Run("IMG_4120.JPG", func(t *testing.T) {
|
||||
fileName := conf.ExamplesPath() + "/IMG_4120.JPG"
|
||||
outputName := conf.ExamplesPath() + "/IMG_4120.json"
|
||||
|
||||
_ = os.Remove(outputName)
|
||||
|
||||
assert.Truef(t, fs.FileExists(fileName), "input file does not exist: %s", fileName)
|
||||
assert.Falsef(t, fs.FileExists(outputName), "output file must not exist: %s", outputName)
|
||||
|
||||
mf, err := NewMediaFile(fileName)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
jsonFile, err := convert.ToJson(mf, false)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if jsonFile == nil {
|
||||
t.Fatal("jsonFile should not be nil")
|
||||
}
|
||||
|
||||
assert.Equal(t, jsonFile.FileName(), outputName)
|
||||
assert.Truef(t, fs.FileExists(jsonFile.FileName()), "output file does not exist: %s", jsonFile.FileName())
|
||||
assert.False(t, jsonFile.IsJpeg())
|
||||
assert.False(t, jsonFile.IsMedia())
|
||||
assert.False(t, jsonFile.IsVideo())
|
||||
assert.True(t, jsonFile.IsSidecar())
|
||||
|
||||
_ = os.Remove(outputName)
|
||||
})
|
||||
|
||||
t.Run("iphone_7.heic", func(t *testing.T) {
|
||||
fileName := conf.ExamplesPath() + "/iphone_7.heic"
|
||||
outputName := conf.ExamplesPath() + "/iphone_7.json"
|
||||
|
|
|
@ -9,7 +9,7 @@ type ConvertJob struct {
|
|||
|
||||
func ConvertWorker(jobs <-chan ConvertJob) {
|
||||
for job := range jobs {
|
||||
if _, err := job.convert.ToJpeg(job.image, false); err != nil {
|
||||
if _, err := job.convert.ToJpeg(job.image, job.convert.conf.JpegHidden()); err != nil {
|
||||
fileName := job.image.RelativeName(job.convert.conf.OriginalsPath())
|
||||
log.Errorf("convert: could not create jpeg for %s (%s)", fileName, strings.TrimSpace(err.Error()))
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ func ImportWorker(jobs <-chan ImportJob) {
|
|||
}
|
||||
|
||||
if !f.HasJpeg() {
|
||||
if jpegFile, err := imp.convert.ToJpeg(f, true); err != nil {
|
||||
if jpegFile, err := imp.convert.ToJpeg(f, imp.conf.JpegHidden()); err != nil {
|
||||
log.Errorf("import: creating jpeg failed (%s)", err.Error())
|
||||
continue
|
||||
} else {
|
||||
|
|
|
@ -28,7 +28,7 @@ func IndexWorker(jobs <-chan IndexJob) {
|
|||
f := related.Main
|
||||
|
||||
if opt.Convert && !f.HasJpeg() {
|
||||
if jpegFile, err := ind.convert.ToJpeg(f, true); err != nil {
|
||||
if jpegFile, err := ind.convert.ToJpeg(f, ind.conf.JpegHidden()); err != nil {
|
||||
log.Errorf("index: creating jpeg failed (%s)", err.Error())
|
||||
continue
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue