I took some photos for a local production of the Wizard of Oz on Monday. For once, I used two cameras – one with a fast 50mm prime lens, the other with my 18-200mm zoom. Everything was fine (except I discovered I managed to set one camera on manual focus for a while – my eyes are not what they used to be, and I find that autofocus is a real boon), until I previewed the images. There was something wrong – some photos seemed to be in the wrong place in the sequence.
Problem was, although I thought I’d set both cameras to the same correct time, it seems that the date/time in one camera was an hour in advance of the other. I usually stick to GMT, but since I was working with another photographer, I set them to BST or so I thought.
I thought that I’d write a simple script to change the time (after all, how difficult could it be?), but I realised that the machine was not set up for scripting in any of my favoured languages. Anyway, I had to get all the files burned by midnight, and it would take a little time to create and debug a new script.
So how easy is it to correct the date and time of a series of images? Easy peasy – people must do it all the time. So fire up Google and look for a script or some tools to do it. All I need to do is:
- select a set of images out of all the images I captured that night
- apply a time adjustment on the times that those images were taken
- rename the files so they have the correct sequence
Selecting a set of images by camera
The first problem is to choose the set of images to modify. There are probably many ways to do this, but what I did was to create two folders (D40 and D200) one for each camera. Fortunately I had two different models of camera.
I sorted the images by the camera type – this is easy in Windows Explorer once you have the trick.
- Open Windows Exporer and find the directory that contains the images
- From the menu or toolbar choose the Details view – this shows a number of columns.
- Right click on the column headers. Windows displays a menu that includes a list of columns and some other options.
- Click More… Windows displays the choose details window.
- Activate Camera Model and click OK. Windows now displays the camera model amongst the details (you may need to scroll the window to see the new column).
- Click on Camera Model column heading to sort by that column. You can now grab all the D200 images (say) and drag them into the appropriate folder.
Modifying the EXIF data to adjust the date
Having created a directory of the files I need to modify, next is to find a tool to change the dates. First thought was simply to change the file date – that way all the files would be in the correct order. The problem is that the file date shows when the file was manipulated (since I did some colour correction, curve adjustment, cropping, and in a few places, rotation) the time that the final file was created bore no relationship to the time the image was taken.
The image file recorded by the camera contains data about the time and camera settings that were used when the photo was taken. This is included as EXIF data. I have a number of EXIF tools and programs that can modify the data, but I couldn’t work out how to do it for a hundred or so images, until I came across exiv2 from http://www.exiv2.org/.
I downloaded that and extracted the zip file into C:\bin. I put the images I wanted to change in D:\images\D200. (The following instructions assume that’s where the files are located).
Pretty well copying the example from the documentation, I wanted to shift the time taken back one hour for all (jpeg) files in a directory.
1. Open a command window. (Press Windows-R and type cmd. Press OK)
2. Change to the drive and directory where the files are located
3. Execute the exiv2 command to adust the file by -1 hour.
c:\bin\exiv2 -a -01 ad *.jpg
The files should not look any different, but the date taken will be different. You can view the Date Taken column in exporer by using the same method that I used to display the camera model above.
So now that the files had the correct date/time taken information in the EXIF information, all I needed to do was to merge the images from the two cameras and rename them so that they appeared in the correct sequence.
I used a program called namexif (http://www.digicamsoft.com/softnamexif.html).
This renamed the files according to the date in the EXIF information.
Namexif is a simple program and doesn’t need installation. Once you launch the program and accept the license agreement, you can add files or directories (including subdirectories) and specify the new name format. The files will be renamed with the date (a few formats are available, and you can add a suffix and optionally the original filename after the date. Worked wonderfully. I chose the 8-character format, so the filenames started with a character sequence like “181AFE85” – looks scary, but it is just a way of packing the date into just 8 characters (same information as 2010-10-25-h19m31s17) so that if you sort by name, they will be in correct order of time taken.
There is usually more than one way to acheive a goal. In this case, I found a couple of tools that allowed me to correct an error in the settings that I used when I took the photos, and to merge the files from two cameras to create a set of images in correct time sequence.
Once I found the tools, it took about two minutes to actually do the job. Pity it took so long to find the tools though!