Raspberry Pi weather webcam

Using a Raspberry Pi and camera module to capture and upload an image to a website

Used packages:

1. ncftp client

apt-get install ncftp

2. imagemagick package to overlay website name and time/date with a semi-transparent background

apt-get install imagemagick

Script I used:

while [ 1 ]; do
 raspistill -q 20 -t 500 -o cam.jpg -w 1280 -h 540
 echo picture taken
 for file in cam.jpg ; do
  convert "$file" -pointsize 15 -fill white -undercolor '#00000050' -gravity NorthWest -annotate +0+0 'MYDOMAIN.COM' "${file}"
  convert "$file" -pointsize 15 -fill white -undercolor '#00000050' -gravity NorthEast -annotate +0+0 "$(date)" "${file}"
 echo ftp upload in progress 
 ncftpput -S .tmp -u ftpuser -p password ftp.mydomain.com / cam.jpg
 # ncftp command syntax
 # ncftpput -S .tmp -u username -p password www.hostname.com path/to/remote/file path/to/local/file
 echo ftp upload finished
 sleep 30

This script is  taking an image every 30 seconds and uploading to a website, the image size is 1280 x 540 pixels (to look more panoramic), jpg quality setting to 20 for smaller file size (q-20) , and is running in a continuous loop.

In ncftpput command i used “-S .tmp” argument,  using a temporary filename when uploading, when upload is complete, this temporary file is renamed to the final filename . This is useful for not viewing a partially uploaded image.

1 thought on “Raspberry Pi weather webcam”

  1. Mustafa YILMAZ


    I used your script. but i encountered below error. Could you please assist me ?

    pictute taken
    ftp upload in progress
    “ncftpput cam.jpg: server said: /cam.jpg.tmp: Permission denied
    ftp upload finished

Leave a Comment

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