Monday, December 15, 2008

Date Imprint on Photos

Just came back from holiday with tonnes of photos to organise. My new camera (8 Mega pixels) that I brought two months ago can only have date imprint if it is set to 2 Mega pixel resolution. With such a low resolution, I may not be able to develop them in 8R or bigger. Anyway, I wouldn't care more about the date. All I care about is resolution and file size. So, no date imprint.

Last night when I was talking to my brother-in-law, I realised that he encountered the same issue. What he did was to source for a Windows freeware to do the date imprint.

Do you know that ImagineMagick can do this job. The best part is that it can run on Cygwin, Windows. Here is my script to do this task, imprint the photo's modified timestamp using Python.

#! /bin/sh
# imprint the modified time of image (in yyyy-mm-dd format) 
# at the bottom right hand corner


    echo "Usage: $0  "
    echo ""

if [ $# -ne 2 ]; then
    exit 1

# find mtime of input image and output as yyyy-mm-dd
ymd=`python -c "import os,datetime;\
    print '%04d-%02d-%02d' % (d.year,d.month,"`

# if you are getting the below error, create a symbolic link to let cygwin
# to point to Windows fonts
#       convert: unable to read font `/usr/lib/ImageMagick-6.4.0/config//usr/share/fonts /corefonts/arial.ttf'.
#       ln -s /cygdrive/c/Windows/Fonts /usr/share/fonts/corefonts
convert "$1" -gravity SouthEast -fill orange -pointsize 60 \
    -draw "text 50,25 '$ymd'" -quality 100 "$2"

Downloaded this picture as a proof-of-concept. Here is the output with -quality 50 to reduce the size.

Labels: , ,


Post a Comment

<< Home