“Print” time and date automatically in a photo

Published by TheJoe on

Estimated reading time: 2 minutes


This article was published more than a year ago, there may have been developments.
Please take this into account.

Today we are insert current date and time in an image using the terminal. By itself, the procedure is not complicated, let's see how.

Meanwhile, we see how to make us say the date and time from PC:

[user@localhost ~]$ echo $(date -R)
Tue, 24 Aug 2010 11:45:04 +0200

And now let's see how place it in the we are interested in using ImageMagick. This program allows us to perform many image manipulation, without having to go through the GUI. There is also a primitive graphical interface, but ImageMagick is mainly used for a number of automation (that soon we will see) command line, the invoked by PHP.

Read more…

Taken from
Use the program convert to convert formats, resize an image, blurcut off, smacchiare, draw, mirror, join, sample and much more. In the section Command Line Processing you will find how to set the command syntax convert.

The program “convert” is also very simple to understand. In this case we want “print” date and time on the photo. The code to enter is this:

[user@localhost ~]$ convert-pointsize 12 -fill white -undercolor black -gravity northwest -draw "text 0,0 'Data: $(date -R)' " /full/path/original.jpg /full/path/output.jpg

I explain the variables below:

-pointsizeThe font size
-fillThe color of the font
-UndercolorThe color of the background
-gravityThe position of the text
-draw “some text here”The text

Of course, then they should indicate the file source and the file destination.

The original
After the trial

Print the date and time on the photo is very useful in the event that we Install a Webcam Weather. The argument has already been gutted a few articles ago, why are superimposed date and time the photo is sufficient edit the file /etc / crontab” as follows:

* *   * * *   joe     streamer -o /home/user/Immagini/webcam/w_image.jpeg
* *   * * *   joe convert-pointsize 12 -fill white -undercolor black -gravity northwest -draw "text 0,0 'Data: $(date -R)' " /full/path/w_image.jpg /full/path/r_image.jpg
* *   * * *   joe cp / home / user / Pictures / webcam / r_image.jpeg / mnt / / webcam /

And here is the final result.

Look here:  Shell: some command to start


I keep this blog as a hobby by 2009. I am passionate about graphic, technology, software Open Source. Among my articles will be easy to find music, and some personal thoughts, but I prefer the direct line of the blog mainly to technology. For more information contact me.


Michele · 19 September 2010 at 3:14 PM

ok, I understand however I use a pretty good webcam that allows me to have even more discrete images’ big so I solved so
streamer -s 640×480 -/ home / user / prova.jpeg

thanks again for your availability’

TheJoe · 19 September 2010 at 1:18 PM

Ciao Michele, and thanks for your comment.

You point out immediately that for the capture of the frame, streamer is based on data from the webcam. In this case, use the webcam netbook, exceedingly small, but if you use a webcam with a few more megapixels you can capture images at higher resolutions. It all depends on the quality of the webcam.

La dicitura “+0200” at the end of the string is no more than an indication of the time slot. Greenwich è and 0000, we should be in +0100, but in reality we end up with daylight saving time +0200. Two hours ahead of Greenwich Mean Time.

Michele · 19 September 2010 at 8:28 AM

great info I was looking for precisely those, I thank you very much for your help, then I wanted to ask if with streamers and’ possible “catch” a larger frame sizes type 640×480 and finally I want to ask what it means that +0200 after the printed schedule

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.