Programmer » jpegdate


Have you ever forgotten to set the timezone of your digital camera before you went on holiday, and want to fix up the timestamps when you get back? Or maybe you have photos taken on two different cameras, but their clocks were set differently, and you want to reconcile them? This free Windows command-line utility comes to the rescue. It can modify JPEG timestamps, and also rename your images according to their timestamp.

Installation: just save jpegdate.exe somewhere convenient. I save it into my windows directory, so I can run it from the command line.

Adjusting the timestamps of your JPEG pictures

Renaming files according to their timestamp

Setting timestamp according to filename

How it works

The source code is available:

jpegdate is copyright (c) 2012 Lucian Wischik. You may use the source code and executable in any derivative work, in any way you wish. I'd appreciate a mention but it's not necessary. The source code demonstrates how to read the EXIF headers of a JPEG, and how to memory-map a file into memory.

Jpegdate scans through your JPEG file (which is assumed to be in the EXIF file format, seemingly used by all digital cameras nowdays). It looks for all TIFF / IFD and SubIFD directories. Within each directory, it looks for tags 0x132 (DateTime), 0x9003 (DateTimeOriginal), 0x9004 (DateTimeDigitized)

When reading the timestamp of an existing file, it looks at DateTimeOriginal first; failing that, it looks for DateTimeDigitized or DateTime. The EXIF specification says that these fields are always stored inside JPEG file as strings of the form "YYYY.MM.DD HH:MM:SS", in the 24-hour clock.

When writing to the timestamps of an existing file, it writes to whichever of those three tags are present. It never adds additional tags. Therefore, if your JPEG lacks any timestamp, this program will never add one.

When calculating new timestamps, it works up from Seconds through to Years one at a time. For instance:

add comment  edit commentPlease add comments here