Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.75k stars 313 forks source link

DateTimeOriginal in image saved from TIFF becomes 1970 when source datetime tags are not set #7134

Open dr-1 opened 1 month ago

dr-1 commented 1 month ago

Short description When saving an output file from a TIFF input that has no EXIF:DateTimeOriginal tag, I noticed RawTherapee populates that tag in the output from EXIF:ModifyDate (interestingly this does not happen when the input is a DNG file). When EXIF:ModifyDate is also not set in the input, EXIF:DateTimeOriginal becomes 1970:01:01 00:00:00 (i.e. Unix epoch) in the saved file, instead of being unset.

Expected behavior I cannot comment on whether the DateTimeOriginal value should be copied from ModifyDate at all — the semantics of the two fields seem different and it creates a problem in my particular workflow, but I am not an EXIF expert. In any case, when a date value is generated in an output file from a tag that is unset in the input, I would expect the target tag in the output file to be unset as well, rather than 1970:01:01 00:00:00.

Steps to reproduce

# Make sure input file has no values in either tag
exiftool -EXIF:DateTimeOriginal= -EXIF:ModifyDate= example.tiff

# Check that there are no other date tags that are already set to 1970 that could be the source of the output value. This should show nothing.
exiftool example.tiff | grep 1970

# Export
rawtherapee-cli -S -j80 -c example.tiff

# Examine output file. This shows a value of 1970:01:01 00:00:00.
exiftool -EXIF:DateTimeOriginal example.jpg

RawTherapee version: 5.10 Operating system version: Linux 6.9.9-arch1-1 x86_64

Lawrence37 commented 1 month ago

The date taken is extracted from the modify date if there is no date taken in the metadata. If the modify date doesn't exist, then it defaults to the first second of 1970. These two commits show it is intentional behavior, but I can't say if it is correct or desirable. 0102fca 2101b84

dr-1 commented 1 month ago

@Lawrence37, thanks for finding that. So this was done intentionally to help with date-based sorting in thumbnail view and prevent falling back on filename sorting when images without date values are present. I guess that will work as desired most of the time, at least if there are no other images that have their DateTimeOriginal values set to before 1970 intentionally (for example when working with digitized historical images). If images are processed further with other tools after RawTherapee has exported them (for example evaluating their metadata to build a catalog), that also requires dealing with those "made up" values of 1970.

I wonder if it would be possible and preferable to deal with missing dates in the function that determines the date-based sort order for the thumbnail view, rather than writing a date to the actual image file for this purpose?