Modification of IPTC metadata changes creation date and time of the picture
Added by Anonymous almost 13 years ago
Hi folks,
I'm using the exiv2 command line utility with Windows XP. Everything works good :-)
But when I've setted the IPTC metadata (e.g. exiv2 -M"set Iptc.Application2.City String Munich" munich.jpg) the creation time and date of the picture (which is displayed in the Windows Explorer) is set to the current time, e.g. 2009-02-14 18:16 instead of 2006-06-01 10:38, when the picture was taken.
Is there any possibility or workaround to avoid that?
Replies (4)
RE: Modification of IPTC metadata changes creation date and time of the picture - Added by Andreas Huggel almost 13 years ago
Yes, if I understand correctly*, check out the manual and look for the -k option.
- I assume you just want to leave the file timestamp as it is. There is also an option to set the file timestamp according to the image creation timestamp in the Exif metadata (-T). But that would require a second exiv2 command, you can't use -T and -M at the same time.
-ahu.
RE: Modification of IPTC metadata changes creation date and time of the picture - Added by Steve Wright about 9 years ago
One thing you should know about Windows and create dates of files and folders.
Bill Gates' definition of a "create date" can be summarized as "whenever a file or directory was moved to its current location or, if created there, that date and time."
Another thing you should know is that, as well as I can remember, this is how Windows Explorer has worked since Windows 98 II. IMO, Microsoft would have done all of us a favor by eliminating "create date" altogether, rather than applying this absurd and illogical (again, just my opinion) definition to their operating system.
Exiv2, being at its roots a tool for Unix and Linux, doesn't acknowledge "create dates" because they don't exist in the aforenamed operating systems. Therefore, you cannot change a "create date" by way of Exiv2.
There are GUI tools for most recent versions of Windows to change the "create date" on a file or folder, singly or in batches. Someone even wrote a Windows version of "touch" (NB: this works best in Win32, and Cygwin BASH will not run it) that has changing the "create date" of items as one of its functions.
I could say more, but as this is a 2+ year old thread I'll leave you with this much to "chew on."
BZT
RE: Modification of IPTC metadata changes creation date and time of the picture - Added by Robin Mills about 9 years ago
Steve
I believe there are three timestamps associated with a file in Windows (dir/? and see the documentation about /t option)
/T Controls which time field displayed or used for sorting timefield C Creation A Last Access W Last Written
Unix has the same concept (see man stat and the output below)
The exiv2 -T option sets A and W using the meta data in Exif.Photo.DateTimeOriginal and leaves C unchanged (exiv2 did not create the file and therefore shouldn't modify C).
C:\temp>for %t in (a,c,w) do dir/t%t x.jpg | findstr x C:\temp>dir/ta x.jpg | findstr x 2012-09-08 20:56 2,038,317 x.jpg C:\temp>dir/tc x.jpg | findstr x 2012-09-12 19:57 2,038,317 x.jpg C:\temp>dir/tw x.jpg | findstr x 2012-09-08 18:56 2,038,317 x.jpg C:\temp>exiv2 -pa -g Date x.jpg Exif.Image.DateTime Ascii 20 2012:09:08 15:25:46 Exif.Photo.DateTimeOriginal Ascii 20 2012:09:08 18:56:39 Exif.Photo.DateTimeDigitized Ascii 20 2012:09:08 18:56:39 Xmp.xmp.ModifyDate XmpText 25 2012-09-08T23:25:46-07:00 C:\temp>exiv2 -M"set Exif.Photo.DateTimeOriginal 2012:09:10 11:12:13" x.jpg C:\temp>exiv2 -T x.jpg C:\temp>for %t in (a,c,w) do dir/t%t x.jpg | findstr x C:\temp>dir/ta x.jpg | findstr x 2012-09-10 11:12 2,038,317 x.jpg C:\temp>dir/tc x.jpg | findstr x 2012-09-12 19:57 2,038,317 x.jpg C:\temp>dir/tw x.jpg | findstr x 2012-09-10 11:12 2,038,317 x.jpg
A little "gotcha" is that UNIX and DOS file systems store their timestamps in UTC. The current exif spec (2.2) does not support timezones, so exiv2 will sets the timestamps assuming that the photograph's timezone is the same as the local computer.
By way of further confusing you, I've listed the attributes using stat on cygwin.
563 rmills@rmills-laptop:/c/temp $ stat x.jpg File: `x.jpg' Size: 2038317 Blocks: 1992 IO Block: 65536 regular file Device: 325f7090h/845115536d Inode: 412642315857843353 Links: 1 Access: (0700/-rwx------) Uid: ( 544/Administrators) Gid: ( 513/ None) Access: 2012-09-10 11:12:13.000000000 -0700 Modify: 2012-09-10 11:12:13.000000000 -0700 Change: 2012-09-12 20:25:31.345675300 -0700 Birth: 2012-09-12 19:57:29.886501400 -0700 564 rmills@rmills-laptop:/c/temp $
You'll see that he calls C=Birth (when I copied the file to c:\temp\x.jpg). He knows the difference between Change and Modify. Change is when I ran exiv2 -T. Modify is the value set by exiv2 in both the A and W attributes of the file.
I think you are correct in believing the "C" time is effectively when the file appeared in its parent directory. You could even argue that this is not a file property and really extended meta-data of the directory concerning the file. Mind you for that matter, a filename isn't a file property either - it's something in the directory. No file knows its own name! (sounds like a line from a country'n'western song).
RE: Modification of IPTC metadata changes creation date and time of the picture - Added by Steve Wright about 9 years ago
Robin,
Thank you for the reply. This is a quick and not too well-considered answer just to keep the thread going, now it's been revived.
I've checked that "Birth" line in Cygwin stat, against synonymous stat commands in BASH shells in other Linuxes (Ubuntu, Fedora, Gentoo to be specific). It seems that Cygwin is the only one that has it, even on the man page. Apparently it's not a "standard" part of stat any more than the -p option (in BSD and Mac OS X) is part of rm (but you probably already knew that).
This is no doubt why I phrased the absence of a "create date" in the operating systems on which Exiv2 as definitively as I did.
Personally I do enough with "touch." with its various options, that the -T option completely escaped my notice. I have had trouble enough, talking of "T", to remember to include it in the XMP "Date" labels I make for my own files when application X or Y get those wrong.
When I have a little more time, I'll go back and read your post in greater depth. If I have any more thoughts, I'll certainly share them here. S
SJW