TheJoe.it Into the (open) source

24Aug/103

“Print” time and date automatically in a photo

webcam

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 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:

Changeable Explanation
-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.

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 / miosito.it / webcam /

And here is the final result.

About

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.

Comments (3) Trackbacks (0)
  1. 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’

  2. 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.

  3. 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 comment

No trackbacks yet.