Tuesday, April 22, 2014

Annotating date on a photo based on EXIF using imagemagick


To annotate date on a digital photo is a breeze. Most cameras (including probably ALL DSLRs) already remove the function to print the date on a photo probably because it is ugly and useless. However, you may need it one day.

How to do it is extremely easy by extracting date from EXIF and print it on a photo using command line:

$ convert your_photo.jpg -font Ariel 96 -fill white -annotate +100+100  %[exif:DateTimeOriginal] output.jpg

This will print the date on the northwestern corner. To print it on a more common place like the good old times, use:

$ convert your_photo.jpg -gravity SouthEast -font Ariel -pointsize 96 -fill white -annotate +100+100  %[exif:DateTimeOriginal] output.jpg

You may want to list available fonts on your system by

$ convert -list font

You may also want to see available EXIF info which you want to print:

$ identify -format %[exif:*] your_photo.jpg 

As usual, you can resize the photo by the way:

$ convert your_photo.jpg -gravity SouthEast -font Ariel -pointsize 96 -fill white -annotate +100+100  %[exif:DateTimeOriginal] -resize 1024x1024 -quality 90 output.jpg

Example photo below:

A more complete example with a bash script is available through this site if you want batch processing. The LCD font is pretty nice :P