Exif Date missing seconds values
lmartin opened this issue · 4 comments
I started from SDK code in "samples/source/ModifyingXMP.cpp".
I just extract XMP metadata from my photo source and reinject it in my new photo.
Fields "Create Date" and "Date/Time Original" are missing seconds values. Here are the values I get when inspecting metadata with exiftool command line:
Photo source:
Create Date : 2021:07:25 12:00:00
Date/Time Original : 2021:07:25 12:00:00
New photo:
Create Date : 2021:07:25 12:00
Date/Time Original : 2021:07:25 12:00:
Thanks for reporting it. Could you please try with the latest release and if the issue still persists, please share the sample test file and the code snippet which you are using.
We've found the same issue and discovered it to be related to this code. Here is a possible patch to fix
index d8dc1daa576..6d4adba85e1 100644
--- a/XMPFiles/source/FormatSupport/ReconcileTIFF.cpp
+++ b/XMPFiles/source/FormatSupport/ReconcileTIFF.cpp
@@ -2706,47 +2706,15 @@ ExportTIFF_Date ( const SXMPMeta & xmp, const char * xmpNS, const char * xmpProp
char buffer[24];
snprintf ( buffer, sizeof(buffer), "%04d:%02d:%02d %02d:%02d:%02d", // AUDIT: Use of sizeof(buffer) is safe.
xmpBin.year, xmpBin.month, xmpBin.day, xmpBin.hour, xmpBin.minute, xmpBin.second );
char buffer[24];
snprintf ( buffer, sizeof(buffer), "%04d:%02d:%02d %02d:%02d:%02d", // AUDIT: Use of sizeof(buff
er) is safe.
xmpBin.year, xmpBin.month, xmpBin.day, xmpBin.hour, xmpBin.minute, xmpBin.second
);
- size_t xmpLen = xmpStr.size();
- if ( xmpLen < 18 ) {
- buffer[17] = buffer[18] = ' ';
- if ( xmpLen < 15 ) {
- buffer[14] = buffer[15] = ' ';
- if ( xmpLen < 12 ) {
- buffer[11] = buffer[12] = ' ';
- if ( xmpLen < 9 ) {
- buffer[8] = buffer[9] = ' ';
- if ( xmpLen < 6 ) {
- buffer[5] = buffer[6] = ' ';
- if ( xmpLen < 1 ) {
- buffer[0] = buffer[1] = buffer[2] = buffer[3] = ' ';
- }
- }
- }
- }
- }
- }
-
tiff->SetTag_ASCII ( mainIFD, mainID, buffer );
- if ( xmpBin.nanoSecond == 0 ) {
-
- tiff->DeleteTag ( kTIFF_ExifIFD, fracID );
-
- } else {
+ snprintf ( buffer, sizeof(buffer), "%09d", xmpBin.nanoSecond ); // AUDIT: Use of sizeof(buffer) is safe.
- snprintf ( buffer, sizeof(buffer), "%09d", xmpBin.nanoSecond ); // AUDIT: Use of sizeof(buffer) is safe.
- for ( size_t i = strlen(buffer)-1; i > 0; --i ) {
- if ( buffer[i] != '0' ) break;
- buffer[i] = 0; // Strip trailing zero digits.
- }
-
- tiff->SetTag_ASCII ( kTIFF_ExifIFD, fracID, buffer ); // ! The subseconds are always in the Exif IFD.
-
- }
+ tiff->SetTag_ASCII ( kTIFF_ExifIFD, fracID, buffer ); // ! The subseconds are always in the Exif IFD.
} catch ( ... ) {
// Do nothing, let other exports proceed.
// ? Notify client?
}
We don't have the context on the original code though. Can someone expand on why it was stripping trailing values, or why xmpStr was reading out with missing zeroes?