Skip to content

Commit

Permalink
Prevent usage of non-capture-related dates
Browse files Browse the repository at this point in the history
  • Loading branch information
naftalibeder committed Aug 22, 2024
1 parent 242a2d6 commit 38ea80d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 1 addition & 5 deletions detaku/convertFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ func convertFile(job ConvertFileJob) (result ConvertFileResult) {
foundDate := false
dateTags := []types.ExifDateTag{}
for _, t := range exifTags.Dates {
// Avoid using exif date tags that describe system activity, like
// FileModificationDateTime.
if !strings.Contains(t.Name, "File") {
dateTags = append(dateTags, t)
}
dateTags = append(dateTags, t)
}
for _, t := range supplExifTags.Dates {
dateTags = append(dateTags, t)
Expand Down
20 changes: 20 additions & 0 deletions exif/exif.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"strconv"
"strings"
"time"

"detaku/lib"
Expand Down Expand Up @@ -108,9 +109,28 @@ func GetAllExifTags(srcPath string) (tags types.ExifTags, err error) {
if err != nil {
continue
}

if d.Unix() == 0 {
continue
}

// Avoid using tags that describe system activity, like
// FileModificationDateTime.
if strings.Contains(n, "File") {
continue
}

// Avoid using tags that are just standalone times without a date component.
if !strings.Contains(n, "Date") {
continue
}

// Avoid using tags that describe dates unrelated to when the file was
// captured, like the creation date of the color profile.
if n == "ProfileDateTime" {
continue
}

tags.Dates[n] = types.ExifDateTag{
Name: n,
Date: d,
Expand Down

0 comments on commit 38ea80d

Please sign in to comment.