Back in the old film days, many compact 35mm cameras came with a feature that can imprint a date/time stamp on the photo. It was typically done by exposing the film with a small embedded LED display that can be turned on or off. It was a great feature for cataloging photographs and making photo records of important events since there isn’t any better way of keeping tracking of the shooting information besides taking old fashioned paper notes. I heard some cameras can record the shooting information on the non-printable film borders but it is not very useful for consumers anyways.

Now most digital cameras do not have this function any more. The shooting information is stored in the digital photo as embedded meta data, or commonly called EXIF tags. We can now keep a lot more information as meta data, you might think we are much better off today. Well, not always. We still print photos. When the photo gets printed on a conventional print paper, none of the meta data gets carried over automatically.  Even if you post your photos in an online albumn or photo sharing site, the shooting date/time information may not be easily accessible either. So adding the shooting time information directly on digital photos are still useful for many people.

Many software developers have obviously thought about the problem and created lots of solutions for doing just that: adding time stamp on digital photos using EXIF information. If you are not very computer savvy or simply lack of the desire to challenge yourself, buying one of them may not be a bad choice since most of them cost only about $10 to $30. For the rest of you, here is a completely free solution, for Windows users at least. Unfortunately I don’t run Mac or Linux so I cannot provide a solution for you but it should be easy to hack up a similar solution using all free software.

If you are still with me on this, check out the photo below. At the bottom right corner, there is a string of white numbers that read “2009:04:11 09:12:22″. This is the shooting date and time superimposed on the original photos.

Easter [with Date Time Stamp]

Here are the simple steps to add time stamp to jpeg photos.

Select or get a font

Microsoft Windows comes with many fonts pre-installed. You can choose any font you like, for example Arial looks great. If you like the one I used, go check out here and download the font called “Digital 7“. Once downloaded, unzip the files, right click on the *.ttf font file then select Install.

Install Imagamagick

Imagemagick is a free software. It is a very powerfull package for manipulating bitmap images. It supports Windows, *NIX, and Mac. We have previous covered some of its uses. Download one of the binary releases and install it.

Give it a try

After sucessfully installing the font and Imagemagick, you are ready to give it a spin. [Windows users] Open a command shell by going to Start->Run and type “cmd” followed by Enter. In the command shell, change the directory to where you have a test photo and type the following command. Replace “your_test_photo.jpg” with the actual photo you want to test and “output.jpg” with your desired output file name.

convert your_test_photo.jpg -font Arial -pointsize 72 -fill white -annotate +100+100  %[exif:DateTimeOriginal] output.jpg

What it does is printing the origial shooting date and time at (100,100) pixels from the top left corner using 72 point (-pointsize option) Arial font (-font option) in white color (-fill option). The command “convert” is part of Imagemagick package. It extracts the shooting date time from Exif tag (%[exif:DateTimeOriginal]), prints the information the way you specified and saves the resulting photo in the output file.

There are many things you can try to customize the time stamp printing. If you like the font in my example photo, it is called “Digital-7-Italic”. You can change the size, color, and location of the text as well.

Automation/batching process

Running the command line is ok for a couple of photos but it is unworkable for many photos. Here is a Windows batch program I created based on another useful windows batch program I found on the Internet. For users of other platforms, it should be possible to automate the process using shell scripts, Perl, or other scripting languages.

SET _bytes=0
SET _count=0
SET _cmd=%1
SET _choice=0
IF NOT DEFINED _cmd SET _cmd=blank
IF %_cmd%==? GOTO :help
IF %_cmd%==/? GOTO :help
FOR /R %%G IN (*.jpg) DO CALL :process %%G
GOTO :total

 IF %_choice%==3 EXIT /B
 SET _inname=%1
 SET _outname=%_inname:~0,-4%_DT.jpg

 IF /I NOT "%_cmd%"=="ADDDT" GOTO :report %1
 IF NOT %_choice%==4 CALL :ask %1
 IF %_choice%==2 EXIT /B
 IF %_choice%==3 ECHO Cancelling, please wait ... && EXIT /B
 CALL :sum %1

 identify -format %%w %_inname% >dttmpfile
 set /p width=<dttmpfile
 Set /a pointsize=%width%/30
 DEL dttempfile
 ECHO Processing %_inname% ...
 convert %_inname% -gravity SouthEast -font "Digital-7-Italic" -pointsize %pointsize% -fill white -annotate +%pointsize%+%pointsize% "%%[exif:DateTimeOriginal]" "%_outname%"

 CHOICE /C YNCA /M "Process %1 (Yes, No, Cancel, All)?"

 CALL :sum %1
 ECHO Found %1

 SET /A _bytes+=%~z1/1000
 SET /A _count+=1

 IF %_bytes%==0 (ECHO No files processed) ELSE (ECHO %_count% matching files, %_bytes%KB)
 GOTO :eof

 ECHO Batch adding Date and Time stamp to all jpg files in the current directory.
 ECHO  New file with name (original name)_DT.jpg will be generated.
 ECHO Run command with ADDDT option to actually process jpg files, otherwise the command only list the files that will be affected.
 ECHO !! No warranty expressed or implied !!
 ECHO !! Use at your own risk             !!

You can copy the code into notepad program and save it as “DTSTAMP.BAT”. To run it, the simplest way is to copy it to the folder that contains the jpg photos you want to add the time stamp, then in command shell window, type “DTSTAMP ADDDT” followed by Enter. For each file it finds, it asks for Y-Yes, N-No, C-Cancel, and A-All. Answering “A” will cause all photos in current folder and its sub-folders to be processed. Running it without the “ADDDT” option will show you only the files that will be affected but no files will be actually processed.

In the batch file, the pointsize for the font is automatically determined by the width of the photo so it may change from photo to photo. The location of the text is always at bottom left corner of the photo. If the default behaviors are undesriable, you are welcome to modify the code any way you want.

If you have trouble copying and saving the batch program. You can download it here: dtstamp

Update (August, 2010): Mac and *nix users check out the shell script version.

Update (June, 2010): Check out the 2nd version of the Windows batch file here.

Posted in: Digital photography, Software on April 12th, 2009. Trackback URI
Keywords: , ,

Related Posts