Brigadoon - An Occasional Corner on the Internet
Sky Camera Image Uploading Software
Designed by Mark Little
 
Now that the sky image has been captured, saved and resized, it is time to upload the image to the web server.This can be accomplished using the command line program "wput". If this program is not already installed, install it with the following commands:

sudo apt-get update
sudo apt-get install wput

Before "wput" can be used to upload the scaled sky camera image, the host's upload parameters need to be obtained. That is, you need to know the account name and password to use to log into the remote site and the address of the remote site and the directory into which the file should be placed. An example of using "wput" is shown below:

wput local_image.jpg ftp://name.pword@ftp.remote.org/remote_image.jpg

In this example, "local_image.jpg" is the local image that you wish to upload. "name" is the account name on the remote site and "pword" is the password on the remote site. "ftp.remote.org" is the address of the remote site and "remote_image.jpg" is the name of the file to be created on the remote site to hold the "local_image.jpg". The local_image and remote_image filename can include the directory in which the files reside or will reside.

Once you have found out what password, username, site address, destination directory and destination filename, you can try to upload the image "/tmp/scale_skyimage.jpg" that is being automatically being creatd by the "/sbin/skycamera.sh" script that runs every five minutes.

There is a bit of a security risk using the command above, since it is possible to see the username and password as the command is being executed using the command above. This risk can be mitigated by placing the username and password for the ftp site in a file. To created this file, enter the following command substituting your favourite editor's name for "nano":

sudo nano /root/.netrc

Enter the following lines with the information relevant to where you wish to upload the image file. You can enter multiple entries if you need to connect to multiple sites.

machine ftp.address.org
login user@somewhere
password your_password

"ftp.address.org" is the address that you need to connect to. It should not include a port number or a protocol designation such as "ftp://" or "http://", etc.

"user@somewhere" is the username that you need to enter to login into the destination computer. The correct username will be provided by the host organisation.

"you_password" is the password that you need to login into the destination computer with the login user name.

Once you have created this file, you should protect it so that no one else can read or write it by using the following command:

sudo chmod 600 /root/.netrc

Once you have your information safely stored in the ".netrc" file, it is time to update the script "/usr/local//sbin/skycamera.sh" to include the uploading of the image file.

#! /bin/bash
#
# Script to capture images from a Raspiberry Pi Camera,
# scale and upload to a web server.
#

# Capture the Image from the Camera
raspistill -o /tmp/skyimage.jpg

# Resize the image to a maximum height of 150 pixels
# (Change size to suit your requirements)
convert /tmp/skyimage.jpg x150 /tmp/scale_skyimage.jpg

# Upload the File to the Host Computer
wput /tmp/scale_skyimage.jpg ftp://ftp.address.org/directory/


# End of Script


The script that is running now is a very basic script that was only written to provide a bit of an explanation of one one method that images can be captured, scaled and uploaded to a site such as WOW or Weather Underground. There are many other options besides the example provided. If you wish use this method, details on a much more robust script and installation process are provided on the following page.
Script Files and Documentation