“Print” time and date automatically in a photo
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.
Taken from imagemagick.org.
Use the program convert to convert formats, resize an image, blur, cut 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:
|-pointsize||The font size|
|-fill||The color of the font|
|-Undercolor||The color of the background|
|-gravity||The position of the text|
|-draw “some text here”||The text|
Of course, then they should indicate the file source and the file destination.
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 / miosito.it / webcam /
And here is the final result.