diff --git a/internal/meta/exif.go b/internal/meta/exif.go index e0bc177ce..3c43d9ccf 100644 --- a/internal/meta/exif.go +++ b/internal/meta/exif.go @@ -13,7 +13,6 @@ import ( "github.com/dsoprea/go-exif/v2/common" "github.com/dsoprea/go-jpeg-image-structure" "github.com/dsoprea/go-png-image-structure" - "github.com/photoprism/photoprism/pkg/fs" "github.com/photoprism/photoprism/pkg/txt" "gopkg.in/ugjka/go-tz.v2/tz" ) @@ -47,7 +46,7 @@ func (data *Data) Exif(fileName string) (err error) { logName := txt.Quote(filepath.Base(fileName)) ext := strings.ToLower(path.Ext(fileName)) - if ext == fs.JpegExt || ext == ".jpeg" { + if ext == ".jpg" || ext == ".jpeg" { jmp := jpegstructure.NewJpegMediaParser() sl, err := jmp.ParseFile(fileName) diff --git a/internal/meta/exif_test.go b/internal/meta/exif_test.go index f80338e93..80906d1ee 100644 --- a/internal/meta/exif_test.go +++ b/internal/meta/exif_test.go @@ -82,7 +82,7 @@ func TestExif(t *testing.T) { assert.Equal(t, "2017-12-21T05:17:28Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z")) assert.Equal(t, "", data.Title) assert.Equal(t, "", data.Keywords) - assert.Equal(t, "DCIM\\100GOPRO", data.Description) + assert.Equal(t, "", data.Description) assert.Equal(t, "", data.Copyright) assert.Equal(t, 180, data.Height) assert.Equal(t, 240, data.Width) diff --git a/internal/meta/sanitize.go b/internal/meta/sanitize.go index e0ecbbf87..d7c15e50f 100644 --- a/internal/meta/sanitize.go +++ b/internal/meta/sanitize.go @@ -7,7 +7,21 @@ import ( ) var UnwantedDescriptions = map[string]bool{ - "OLYMPUS DIGITAL CAMERA": true, + "OLYMPUS DIGITAL CAMERA": true, // Olympus + "rhdr": true, // Huawei + "hdrpl": true, + "fbt": true, + "mon": true, + "nor": true, + "dav": true, + "mde": true, + "edf": true, + "btfmdn": true, + "btf": true, + "btfhdr": true, + "frem": true, + "oznor": true, + "rpt": true, } // SanitizeString removes unwanted character from an exif value string. @@ -49,6 +63,8 @@ func SanitizeDescription(value string) string { if remove := UnwantedDescriptions[value]; remove { value = "" + } else if strings.HasPrefix(value, "DCIM\\") && !strings.Contains(value, " ") { + value = "" } return value diff --git a/internal/meta/sanitize_test.go b/internal/meta/sanitize_test.go index cee6127c2..823eaf8c3 100644 --- a/internal/meta/sanitize_test.go +++ b/internal/meta/sanitize_test.go @@ -52,4 +52,36 @@ func TestSanitizeDescription(t *testing.T) { t.Fatal("result should be empty") } }) + + t.Run("GoPro", func(t *testing.T) { + result := SanitizeDescription("DCIM\\108GOPRO\\GOPR2137.JPG") + + if result != "" { + t.Fatal("result should be empty") + } + }) + + t.Run("hdrpl", func(t *testing.T) { + result := SanitizeDescription("hdrpl") + + if result != "" { + t.Fatal("result should be empty") + } + }) + + t.Run("btf", func(t *testing.T) { + result := SanitizeDescription("btf") + + if result != "" { + t.Fatal("result should be empty") + } + }) + + t.Run("wtf", func(t *testing.T) { + result := SanitizeDescription("wtf") + + if result != "wtf" { + t.Fatal("result should be 'wtf'") + } + }) }