Adding date time stamp to a jpg picture - Raspberry Pi Forums
Posts: 9
Joined: Wed Oct 02, 2013 5:54 am
Adding date time stamp to a jpg picture
Hello.
I’m a complete beginner and I’m trying to convert my Raspberry Pi in a weather cam. I’m not interested in streaming, I’m using a camera module and some raspistill commands in order to take a picture of a landscape every 5 minutes. Then I send the picture to my website using ftp. Everything is going fine but now I need help to add a couple of informations like my website and date time stamp to a jpg picture shot.
Here’s an example of what I’d like to obtain:
At the moment I use this bash script:
Code: Select all
#!/bin/bashTMP='/tmp'OUTPUT_FILE='webcam.jpg'OPTIONS='-w 800 -h 600 -q 80'cd $TMPraspistill -o $OUTPUT_FILE $OPTIONS/usr/local/bin/send-ftp $OUTPUT_FILE
How can I modify it? The goal is adding to the jpeg image a colored band with my website url on the left and date and hour of the shot on the right? Any suggestion?
Last edited by MrPippoTN on Sat Oct 05, 2013 7:09 am, edited 2 times in total.
Posts: 14705
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
Posts: 37181
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Re: Adding date time stamp to a jpg picture
Update your program running raspistill to have the -exif flag.
Install ImageMagick with
Try this shell script:
Code: Select all
#!/bin/bashfor file in *.jpg ; doconvert "$file" -font arial.ttf \-pointsize 72 -fill white -annotate +100+100 \%[exif:DateTimeOriginal] "new-${file}"done
That reads the EXIF data in filename.jpg and writes a new new-filename.jpg (in the same directory) with the date/time as an additional visible layer.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you’ll get a ban.
Any DMs sent on Twitter will be answered next month.
This is a doctor free zone.
Posts: 9
Joined: Wed Oct 02, 2013 5:54 am
Re: Adding date time stamp to a jpg picture
DougieLawson wrote:Update your program running raspistill to have the -exif flag. Install ImageMagick with Try this shell script: Code: Select all ```
!/bin/bash
for file in *.jpg ; do convert “$file” -font arial.ttf \ -pointsize 72 -fill white -annotate +100+100 \ %[exif:DateTimeOriginal] “new-${file}” done
> That reads the [EXIF](http://en.wikipedia.org/wiki/EXIF) data in filename.jpg and writes a new new-filename.jpg (in the same directory) with the date/time as an additional visible layer.Thank you, I'll try it tonight. Meanwhile, I've another question: and if my picture has no exif informations?---[jamesh](https://www.raspberrypi.org/forums/memberlist.php?mode=viewprofile&u=406&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec)Raspberry Pi Engineer & Forum Moderator<br />**Posts:** [25108](https://www.raspberrypi.org/forums/search.php?author_id=406&sr=posts&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec)**Joined:** Sat Jul 30, 2011 7:41 pm<a name="9a21e1ac"></a>### [Re: Adding date time stamp to a jpg picture](#p431839)[Thu Oct 03, 2013 3:25 pm](https://www.raspberrypi.org/forums/viewtopic.php?p=431839&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec#p431839)> MrPippoTN wrote:> > DougieLawson wrote:Update your program running raspistill to have the -exif flag.> Install ImageMagick with> Try this shell script:> Code: [Select all](#)>
!/bin/bash
for file in *.jpg ; do convert “$file” -font arial.ttf \ -pointsize 72 -fill white -annotate +100+100 \ %[exif:DateTimeOriginal] “new-${file}” done
> That reads the [EXIF](http://en.wikipedia.org/wiki/EXIF) data in filename.jpg and writes a new new-filename.jpg (in the same directory) with the date/time as an additional visible layer.> Thank you, I'll try it tonight. Meanwhile, I've another question: and if my picture has no exif informations?The date and time should be in there if the pictures were taken with a recent RaspiStill..Principal Software Engineer at Raspberry Pi (Trading) Ltd.<br />Contrary to popular belief, humorous signatures are allowed. Here's an example...<br />“I own the world’s worst thesaurus. Not only is it awful, it’s awful."---[MrPippoTN](https://www.raspberrypi.org/forums/memberlist.php?mode=viewprofile&u=85856&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec)**Posts:** [9](https://www.raspberrypi.org/forums/search.php?author_id=85856&sr=posts&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec)**Joined:** Wed Oct 02, 2013 5:54 am<a name="d0b1d4c1"></a>### [Re: Adding date time stamp to a jpg picture](#p432171)[Fri Oct 04, 2013 6:38 am](https://www.raspberrypi.org/forums/viewtopic.php?p=432171&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec#p432171)It works, thank you. Now I can see the date in this format:<br />yyyy:mm:dd hh:mm:ssIs it possible to change this? I'd like to get:<br />dd/mm/yyyy hh:mmAnother little question. Now I put the datestamp in the lower right corner but it is white, so it's difficult to read. Can I put a layer with a black horizontal band at the bottom of the picture?Thank you in advance.------[MrPippoTN](https://www.raspberrypi.org/forums/memberlist.php?mode=viewprofile&u=85856&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec)**Posts:** [9](https://www.raspberrypi.org/forums/search.php?author_id=85856&sr=posts&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec)**Joined:** Wed Oct 02, 2013 5:54 am<a name="f0d7c028"></a>### [Re: Adding date time stamp to a jpg picture](#p432720)[Sat Oct 05, 2013 7:08 am](https://www.raspberrypi.org/forums/viewtopic.php?p=432720&sid=bf91a0cdced1b37d4aa7e5f9145ec7ec#p432720)I think I've done it. I used Imagemagick to compose the final image (webcam.jpg) using a layer (striscia.png)<br />Thank you very much!!!These are my two files:shot:Code: [Select all](#)
!/bin/sh
OPTIONS=’-w 800 -h 600 -q 80 -x’ DATE=$(date +”%d/%m/%Y”) HOUR=$(date +”%R”)
cd /tmp raspistill -o image.jpg $OPTIONS composite -gravity center striscia.png image.jpg pre_webcam.jpg
convert pre_webcam.jpg -font Arial \ -pointsize 14 -fill white -annotate +670+590 \ $DATE \ -pointsize 14 -fill white -annotate +750+590 \ $HOUR \ -pointsize 14 -draw “gravity southwest \ fill white text 15,6 ‘Trento, 200 m s.l.m. - Raspberry Pi Cam by GeekSolution.it’ “ \ webcam.jpg
/usr/local/bin/send-ftp webcam.jpg done
send-ftp:Code: [Select all](#)
!/bin/sh
TMP=’/tmp’ HOST=”ftp.mywebsite.it”
This is the FTP user that has access to the server.
USER=’myusername’
This is the password for the FTP user.
PASSWD=’mypassword’
It is the first argument passed to the script.
FILE=”$1”
cd $TMP ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD cd mywebsite/folder/ put $FILE quit END_SCRIPT exit 0 ```
Posts: 9
Joined: Wed Oct 02, 2013 5:54 am
Re: Adding date time stamp to a jpg picture
As I wrote at the beginning of the topic, I’m a complete beginner. I don’t know anything in coding, I got some good advices that you can read here and then I studied imagemagick. Everything I did, I wrote it here.
There are links and code to copy. Please just try and eventually let me know.
Regards.
Posts: 12
Joined: Thu Aug 01, 2013 4:59 am
Location: Down Under
Contact: Website
Forum Moderator

Posts: 279
Joined: Mon Nov 07, 2011 9:12 am
Location: UK
Contact: Website




