Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving Exif IFD0:Date/Time in (possibly) the wrong format. #686

Open
mbmast opened this issue Nov 22, 2024 · 4 comments
Open

Retrieving Exif IFD0:Date/Time in (possibly) the wrong format. #686

mbmast opened this issue Nov 22, 2024 · 4 comments

Comments

@mbmast
Copy link

mbmast commented Nov 22, 2024

Possible issue, not really certain.

Using metadata-extractor-2.19.0.jar against the attached file, I get the following metadata tag Exif IFD0:Date/Time value: Sat Feb 04 18:44:14 2006. Isn't this formatted incorrectly for this tag? Shouldn't it be formatted like this: YYYY:MM:DD HH:MM:SS?

fd70467fa959724e3570d3f9ee513a9d84a097fe

@drewnoakes
Copy link
Owner

Can you share your code? It's possible that the date is being parsed and reformatted on your machine to a local culture's date format.

@DAN-MU-ZI
Copy link
Contributor

@mbmast @drewnoakes This issue arises because the DateTime field in the Exif metadata is stored in RFC 2822 format as ASCII values, rather than following the Exif DateTime format ("YYYY:MM:DD HH:MM:SS"). The current implementation does not handle this discrepancy and simply outputs the stored value. To address this, it seems necessary to implement additional processing, such as delegating the responsibility of handling this field to ExifIFD0Descriptor, to ensure proper formatting or error handling in compliance with Exif standards.

For reference, the Exif standard specifies the required DateTime format on page 44 of the official document: Exif Standard (CIPA DC-008-2012).

@drewnoakes
Copy link
Owner

image

Sat Feb 04 18:44:14 2006 is the value stored in the image. As @DAN-MU-ZI says, this is not the expected format. You can try and parse it yourself if you like.

The library does go to some effort to try and parse the date when it can, but it doesn't support this format. See:

if ((o instanceof String) || (o instanceof StringValue)) {
// This seems to cover all known Exif and Xmp date strings
// Note that " : : : : " is a valid date string according to the Exif spec (which means 'unknown date'): http://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif/datetimeoriginal.html
String datePatterns[] = {
"yyyy:MM:dd HH:mm:ss",
"yyyy:MM:dd HH:mm",
"yyyy-MM-dd HH:mm:ss",
"yyyy-MM-dd HH:mm",
"yyyy.MM.dd HH:mm:ss",
"yyyy.MM.dd HH:mm",
"yyyy-MM-dd'T'HH:mm:ss",
"yyyy-MM-dd'T'HH:mm",
"yyyy-MM-dd",
"yyyy-MM",
"yyyyMMdd", // as used in IPTC data
"yyyy" };

Sharing your code would be helpful.

@mbmast
Copy link
Author

mbmast commented Nov 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants