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.
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.
@ECHO OFF SETLOCAL 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 :process 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%" EXIT /B :ask CHOICE /C YNCA /M "Process %1 (Yes, No, Cancel, All)?" SET _choice=%ERRORLEVEL% EXIT /B :report CALL :sum %1 ECHO Found %1 EXIT /B :sum SET /A _bytes+=%~z1/1000 SET /A _count+=1 EXIT /B :total IF %_bytes%==0 (ECHO No files processed) ELSE (ECHO %_count% matching files, %_bytes%KB) GOTO :eof :help ECHO. ECHO DTSTAMP [ADDDT] ECHO. 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. ECHO Run command with ADDDT option to actually process jpg files, otherwise the command only list the files that will be affected. ECHO. 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: Mac and *nix users check out the shell script version.
Keywords: Date Time Stamp, exif, Metadata
|
|
|
Twit This Post! |
Print This Post
|
![Easter [with Date Time Stamp]](http://farm4.static.flickr.com/3378/3436505763_6e63b108c8.jpg)



hi max,
thanks for the interesting post. if you’re interested in a bash version of the
script (for mac and linux), feel free to drop me a line.
regards,
sb
From what I read from your posting, I am pretty much interested in trying out this.
When ?I started following the steps, you have mentioned I am getting errors. I am giving the errors shown.
K:\pictures\test>dtstamp adddt
‘CHOICE’ is not recognized as an internal or external command,
operable program or batch file.
Missing operand.
‘identify’ is not recognized as an internal or external command,
operable program or batch file.
Missing operand.
Could Not Find K:\pictures\test\dttempfile
Processing K:\pictures\…
Invalid Parameter – -gravity
No files processed
I have Windows XP Pro
What am I doing wrong? Any help will be greatly appreciated.
Sorry. The batch was tested on Windows Vista. There must be some differences between XP and Vista batch.
The quickest way to get around of the CHOICE problem is to delete the line then change the next line to “SET _choice=4″. This will stop asking if you want to process each file but instead process all of them. I will post a better solution later for XP users.
“identify” is part of ImageMagick package. If you have installed it but it still does not work, you may need to add the executable path to Windows Environment. Check this to find out how.
http://www.computerhope.com/issues/ch000549.htm
Thanks.
Max
Thanks for the script. I’m a XP user and noticed that I have a windows system file called convert that is used to disk partions etc. Once I added my path to the file it started to work but has problems with directories with a space. I will see what I can do to fix the xp problems.
To fix directories with a space, change this line (top part):
FOR /R %%G IN (*.jpg) DO CALL :process %%G
To this:
FOR /R %%G IN (*.jpg) DO CALL :process “%%G”
what about files with spaces? I saw the part about directories with space (Win XP here)
Please share the batch scripts for MAC mentioned on
8 Responses to “How to Add Date Time Stamp to JPEG Photos Using Free Software”
I need the date and time stamps on the photos for work…so far the alternatives are too complicated, for what should be simple! (to those with the grand knowledge of how)
By any chance, would this script work for import DV from a video camera? I know the XIF data is in there, but how can I Make it appear in the video?
Great instruction, helped a lot!
Thank you!
Somehow the convert command doesn’t work in the batch file (Invalid Parameter – and), but the exact same thing works when I enter it manually…
Never mind, it was (somehow) using window’s convert. problem solved
Thanks a ton!!!
You are welcome. It makes me happy whenever someone finds my blog useful.
Max
Just a question. Will the time stamp on the meta data follow the time settings of the camera that one uses? I use my phone to take pictures with and usually the time stamp on the file will follow the time zone I set my phone with. Is it the same thing with meta data?
Yes. The time from the built-in clock is recorded. It is not clear how the time zone information is handled in other cameras but in my test the local time is used.
Max
Thanks! I finally have cleared.^_^
Thanks for the tip.
I am wondering though, is this software lossless? Like does it reprocess the whole photo after it adds the date/time stamp, or only the little corner where the date/time is added.