diff --git a/internal/meta/exif_parser.go b/internal/meta/exif_parser.go index 8830d49e9..3add9ef15 100644 --- a/internal/meta/exif_parser.go +++ b/internal/meta/exif_parser.go @@ -56,18 +56,18 @@ func RawExif(fileName string, fileType fs.FileFormat) (rawExif []byte, err error if err != nil { return rawExif, fmt.Errorf("metadata: %s in %s (parse png)", err, logName) - } - - _, rawExif, err = cs.Exif() - - if err != nil { - if err.Error() == "file does not have EXIF" { - return rawExif, fmt.Errorf("metadata: found no exif header in %s (parse png)", logName) - } else { - log.Infof("metadata: %s in %s (parse png)", err, logName) - } } else { - parsed = true + _, rawExif, err = cs.Exif() + + if err != nil { + if err.Error() == "file does not have EXIF" || strings.HasPrefix(err.Error(), "no exif data") { + return rawExif, fmt.Errorf("metadata: found no exif header in %s (parse png)", logName) + } else { + log.Infof("metadata: %s in %s (parse png)", err, logName) + } + } else { + parsed = true + } } } else if fileType == fs.FormatHEIF { heicMp := heicexif.NewHeicExifMediaParser() @@ -76,18 +76,18 @@ func RawExif(fileName string, fileType fs.FileFormat) (rawExif []byte, err error if err != nil { return rawExif, fmt.Errorf("metadata: %s in %s (parse heic)", err, logName) - } - - _, rawExif, err = cs.Exif() - - if err != nil { - if err.Error() == "file does not have EXIF" { - return rawExif, fmt.Errorf("metadata: found no exif header in %s (parse heic)", logName) - } else { - log.Infof("metadata: %s in %s (parse heic)", err, logName) - } } else { - parsed = true + _, rawExif, err = cs.Exif() + + if err != nil { + if err.Error() == "file does not have EXIF" || strings.HasPrefix(err.Error(), "no exif data") { + return rawExif, fmt.Errorf("metadata: found no exif header in %s (parse heic)", logName) + } else { + log.Infof("metadata: %s in %s (parse heic)", err, logName) + } + } else { + parsed = true + } } } else if fileType == fs.FormatTiff { tiffMp := tiffstructure.NewTiffMediaParser() @@ -96,18 +96,18 @@ func RawExif(fileName string, fileType fs.FileFormat) (rawExif []byte, err error if err != nil { return rawExif, fmt.Errorf("metadata: %s in %s (parse tiff)", err, logName) - } - - _, rawExif, err = cs.Exif() - - if err != nil { - if err.Error() == "file does not have EXIF" { - return rawExif, fmt.Errorf("metadata: found no exif header in %s (parse tiff)", logName) - } else { - log.Infof("metadata: %s in %s (parse tiff)", err, logName) - } } else { - parsed = true + _, rawExif, err = cs.Exif() + + if err != nil { + if err.Error() == "file does not have EXIF" || strings.HasPrefix(err.Error(), "no exif data") { + return rawExif, fmt.Errorf("metadata: found no exif header in %s (parse tiff)", logName) + } else { + log.Infof("metadata: %s in %s (parse tiff)", err, logName) + } + } else { + parsed = true + } } } diff --git a/internal/meta/exif_test.go b/internal/meta/exif_test.go index 559d8d2e6..00ed32d69 100644 --- a/internal/meta/exif_test.go +++ b/internal/meta/exif_test.go @@ -108,7 +108,7 @@ func TestExif(t *testing.T) { t.Fatal("err should NOT be nil") } - assert.Equal(t, "metadata: found no exif header in tweethog.png (search and extract)", err.Error()) + assert.Equal(t, "metadata: found no exif header in tweethog.png (parse png)", err.Error()) }) t.Run("iphone_7.heic", func(t *testing.T) {