Page 1 of 1

Add system date & time to image

Posted: 2013-10-07T19:32:53-07:00
by yds
I want to be able to add the system time and date (not EXIF tag data) to an image running from command line. For the life of me, I cannot figure out how to get the system date. I am using IM on linux. (I have found on windows I can use %TIME% to return the system date and time, but doesn't work on linux). Here's an example, and I'm not sure what to put in place of SYSTEM_TIME_HERE to get the system date/time to annotate. Any help appreciated.

Code: Select all

convert source.jpg -pointsize 24 -fill white -undercolor '#00000080' -gravity SouthEast -annotate +0+5 SYSTEM_TIME_HERE output.jpg

Re: Add system date & time to image

Posted: 2013-10-07T19:56:55-07:00
by fmw42
datetime=`date`
echo $datetime
Mon Oct 7 19:55:11 PDT 2013

so get date info and put into a variable and then use the variable in the IM command -annotate, but put it in double quotes.


datetime=`date`
convert source.jpg -pointsize 24 -fill white -undercolor '#00000080' -gravity SouthEast -annotate +0+5 "$datetime" output.jpg

Re: Add system date & time to image

Posted: 2013-10-07T20:15:54-07:00
by yds
Perfect! Thanks. Wasn't sure how to do both from one commandline, but tried it and worked beautifully!

Re: Add system date & time to image

Posted: 2013-10-07T20:25:26-07:00
by fmw42
this also works in one command line:

convert source.jpg -pointsize 24 -fill white -undercolor '#00000080' -gravity SouthEast -annotate +0+5 "$(date)" output.jpg