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

sudo apt-get update
sudo apt-get install imagemagick

Once this program is installed, an image can be resized using command line instructions. This allows the "skycamera.sh" script to be updated to scale the image already captured from the camera and placed in the "/tmp" directory. To resize the image so that it is 150 pixels high (width scaled in proportion), enter the following command at the prompt:

convert /tmp/skyimage.jpg 150 /tmp/scale_skyimage.jpg

To convert the image such that the width is fixed at 150 pixels and the height is scaled accordingly, use the command:

convert /tmp/skyimage.jpg x150 /tmp/scale_skyimage.jpg

After you have tired this command with the size requirements for site to which the image will be uploaded, it is time to modify the script using the command  "sudo nano /usr/local/sbin/skycamera.sh" to add the new command (where "nano" represents your favourite editor.

#! /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

# End of Script


Once this script has been saved, wait five (5) minutes and then look in the "/tmp" directory for the file "scale_sky_image.sh" which should be 150 pixels wide, with the height scaled proportionally.

Once you have confirmed that image scaling is working correctly, the only requirement left is to upload the scaled image file to the web server.