Sunday, January 18, 2009

Fixing wrong date/times within a photo and setting the correct file time

I keep forgetting to correct the camera's time when changing back & forth from daylight savings. So a stack of my photo's are 1 hour behind. This is how I did it and present some of my research findings


My goal is to keep the photo byte-for-byte the same, except changing the embedded dates. This means I can easily verify that the process hasn't changed anything else (by doing a byte comparison). It also means backups are easier because a tiny binary change is required for each photo, not needing to do a full copy. Versioning systems that handle binary data like SVN, Git & Mercurial will find these changes very compact (making everyone happy :-).

  1. Modify all the embedded date/times so they are moved forward 1 hour.
  2. Change the file time of the photo to match the embedded Date Taken.
Programs used
  • Exifier v2.1.5 (build 263) Graphical image manage & metadata editor. No updates since 2002!!
  • Exiv2 v0.18 Console app, easy to use (nice syntax/manual)
  • ExifTool v7.62 Console app, Perl based but compiled for Windows. Has a million options, but hard to find all the right options (a bit of a rabbits warren).

Fixing the EXIF date/time within a photo

Most photo's taken with a digital camera will have 3 date/time's in them.

  • Date Taken
  • Date Digitised
  • Date Modified

Date Taken is the most important one, as that is what Windows Explorer and most Photo editors/viewers use. Usually they are all the same, unless the photo has been edited in some way.

Therefore, I'm trying to change all the embedded date/times by 1hour, relative to their original time. All these programs let you specify the relative time to alter.

This comes in handy if you notice that the camera is the wrong time, but not just a simple Daylight Savings difference of 1 hour.
Before you change the camera's time to the correct time, take a photo of a clock with the correct time. Ideally a GPS (which has to always have the correct time & sync's it with satellites) or something that shows seconds and has an accurate time. Then on the computer, look at the photo's time & the clock's time to work out the relative difference. You can then use this when fixing the time of photos.

ProgramversionByte for byte?Time (min)
Exifer2.1.5Yes2:121 (1:532)

1. Wall clock time
2. Exifer preloads all the EXIF data when selecting a folder, which means a lot of the Images are in the OS filesystem cache (cheating, kind of :-).
3. Looks like there are sections of the EXIF header removed, as well as random bytes have changed (looks like it might still have the same information). But it makes it very hard to verify proper changes, and stuff's up byte diffs for backup/version control.

You can see that the Exiv2 guys have been working hard on performance, making some serious improvements between v0.17 & v0.18.

Setting the photo's file time to match the EXIF date/time

Since we have changed the embedded date/time, the date/time of the file will not match, and it makes it much more convenient if the photo's file time is correct.

Programversion Time (seconds)
Exifer2.1.54 531 (22)
Exiv20.18 7.02
0.17.1 13.81
ExifTool7.62 14.64
7.25 15.16

Notes: 4. For some reason, Exifer creates a hidden "descript.ion" file that is empty in the folder. Can't find an option to turn that off, and there aren't many programs that use descript.ion anymore (used to be used in DOS days to enter a description for files within a directory, since images didn't always support some kind of embedded metadata).

Warning: NTFS formatted drives will show a different time when you change into Daylight Savings time, as NTFS saves file times in UTC (GMT) which is universal time and has not timezone offset. When your region moves into Daylight Savings time, your timezone offset from UTC changes, therefore Windows displays a different time. FAT32 stores only the local time, so it doesn't change with Daylight Savings changes. Camera memory cards (SD, Memory Stick, Compact Flash etc.) are Fat16 or Fat32 formatted, and some external backup drives are also FAT32 formatted. Assuming the file time has been set to the Date Taken time, these will always match.


  1. For normal usage, use Exifer to altering EXIF date/times & make file times match.
    If wanting to automate (using batch files etc.), use Exiv2.
  2. Keep all your photo's & any backups on the same formatted drive. I have everything on FAT32 formatted drives, but if you are going to be on NTFS for one, use NTFS for all (not typical with camera memory cards & USB falsh drives).

Test Specifications

  • Acer Travelmate 3220 Notebook
  • Windows XP SP3
  • Intel Pentium M 2.26Ghz
  • 2.26Ghz 1Gb
  • Toshiba MK8025GAS HDD
    • 2.5" 80GB
    • 4,200rpm
    • 8MB Buffer
    • ATA-6 Interface
    • 12ms Average Seek Time
    • NTFS formatted
  • Photo's taken with a Panasonic Lumix TZ-11 8Mpixel camera
    • All contained within a single folder
    • 251 photo's
    • Total size of 769MB (806,767,153 bytes)
    • Average size of 3.07MB (3,214,212 bytes)
  • All devices deactivated where possible
    • Wireless LAN turned off
    • Bluetooth turned off
    • CardBus turned off
    • LAN turned off
    • Firewire (IEEE1394) turned off
    • Extrenal drives disconnected
  • All programs shutdown where possible
    • Anti-virus turned off
    • Programs in system tray terminated
    • Explorer windows closed Had to retest when realised I had explorer opened on test directory, meaning Windows was updating the view during the test
  • Between test, Operating System File cache cleared by copying very large files (is there a better way/utility to do this for you?

Test commands

Fix wrong time
  • Select images as needed (can show sub-folders as well)
  • "Edit EXIF/IPTC data" (Ctrl+E)
  • Select "EXIF data" tab
  • Select "Date" sub-tab
  • Tick [x] Apply to Date modified and Date digitized
  • Adjust "Date/Time offset" settings as needed
Set file date/time to match EXIF date
  • Select images as needed (can show sub-folders as well)
  • "Rename/redate images" (Ctrl+N)
  • Untick [ ] Rename
  • Tick [x] Redate (by EXIF date fields)

Note: Sets Fat32 2sec accuracy time on NTFS


Note: For testing Exiv2 & ExifTool, I wrapped the console commands in echo %time% to find out the elapsed time to run (I'm sure there's a nice chuck of DOS batch code that even does the duration time calculation for you).

Fix wrong time

exiv2.exe ad -a 1 -k *.jpg

  • ad -a 1 adds 1 hour to all 3 EXIF times (can use 1:03; -0:34.57 etc.)
  • -k keeps current file time
Set file date/time to match EXIF date

exiv2.exe mv -T *.jpg
Note: Sets 1sec accuracy time on NTFS
Manual talks about having to set TZ enviroment variable, but seems to work fine without...

Fix wrong time

exiftool.exe -overwrite_original -P -AllDates+=1 ./*.jpg

  • -AllDates+=1 adds 1 hour to all 3 EXIF times
  • -P keeps current file time
  • -overwrite_original doesn't create a backup copy of the image
Set file date/time to match EXIF date

exiftool "-DateTimeOriginal>FileModifyDate" ./*.jpg
Note: Sets 1sec accuracy time on NTFS

Please suggest any other programs or configurations to try...