No probs, it comes in three parts, the script, the radar config and the satellite config. Oh and the crontab entries. Also need iimagemagick installed for the image stuff.
Script:
#!/bin/bash
# 2DO
# -
# Read in Configuration File, bail if not possible.
if [[ -f $1 ]];then
source $1
else
echo " Must specify the Configuration file on commandline using"
echo " the full path (eg: /home/XXXXX/.bin/bomRadarAnim.cfg) !!!"
exit 1
fi
# Change to Working Directory.
here="$(pwd)"
cd ${baseDir}/${stillDir}
############ BEGIN COMPOUND VARS ############
# Get time from 'timeVector's secs ago.
ts=$(($(date +%s)-timeVector))
# Convert it to timestamp format dd-mm-yyyy hh:mm.
timeStamp=$(date -d @${ts} '+%d-%m-%Y %H:%M')
# Convert it to file timestamp format yyyymmdd_hhmm.
fileTimeStamp=$(date -d @${ts} '+%Y%m%d_%H%M')
# Setup Filenames.
outFile="${animPrefix}_${fileTimeStamp}.gif"
inFile="${stillPrefix}_${fileTimeStamp}.${stillFormat}"
# Massage Timestamp Locations to 'Convert' args.
tsLocation="+${timeStampLocX}+${timeStampLocY}"
# Calculate Images needed for Animation.
animLength=$((${animLength}*${imagesPerHour}+1))
# Generate 'Convert' Location args.
circleArgs="${locationX},${locationY} ${locationX},$((locationY+locationRadius))"
############# END COMPOUND VARS #############
################ BEGIN WORK ################
# Download and Timestamp File, Exit on Fail ...
# Get MD5sum of Previous File.
prevFile=$(ls -r|head -1); prevMD5=$(md5sum -b ${prevFile}|cut -d ' ' -f1)
# Download
wget -t10 -O ${inFile} ${stillSource} >/dev/null 2>&1
# Get MD5sum of Downloaded File.
currMD5=$(md5sum -b ${inFile}|cut -d ' ' -f1)
# Check whether File exists, is > zero bytes or isn't same as previous.
if [[ ! -s ${inFile} || ${currMD5} = ${prevMD5} ]];then
# Must not exist, is zero bytes or is same as previous, delete it.
rm -f ${inFile}
# No file to work with, raise an Error and BAILOUT !
echo " Download of ${inFile} Failed !!!"
if [[ ${currMD5} = ${prevMD5} ]];then echo " Identical to Last File.";fi
exit 1
fi
# Crop if Needed.
if [[ -n ${cropXY} ]];then
convert ${inFile} -crop ${cropXY} +repage -layers Optimize ${inFile}
fi
# Place Timestamp and Location on Image.
convert ${inFile} -fill ${timeStampColor} -font ${timeStampFont} -pointsize ${timeStampFontSize} -annotate ${tsLocation} "${timeStamp}" +repage -layers Optimize -strip -quality ${imgQual} ${inFile}
convert ${inFile} -fill ${locationColor} -stroke ${locationColor} -draw "circle ${circleArgs}" +repage -layers Optimize ${inFile}
# Buld Animation.
animStills="$(ls -r|head -${animLength}|sort)"
convert -delay ${animDelay} -loop 0 ${animStills} -layers Optimize ${baseDir}/${animDir}/${outFile}
# Create Generic Link to Latest Anim
cd ${baseDir}
ln -f -s ${animDir}/${outFile} ${animPrefix}.gif
# Houskeeping
numStills2Del=$(($(ls ${stillDir} -1|wc -l)-(24*stillKeepDays*imagesPerHour+1)))
numAnims2Del=$(($(ls ${animDir} -1|wc -l)-(24*animKeepDays*imagesPerHour+1)))
if (( ${numStills2Del} > 0 )); then rm -f $(ls ${stillDir}/*|head -${numStills2Del}); fi
if (( ${numAnims2Del} > 0 )); then rm -f $(ls ${animDir}/*|head -${numAnims2Del}); fi
cd ${here}
################# END WORK #################
# BASIC LOGIC
# start in stills dir
# dl/ts
# crop ?
# add ts/loc to img
# create anim automagically in ../anims dir
# cd to baseDir
# force create link to anim
# housekeeping
Radar config
# Radar Images
# - maked in 10min intervals
# - produced 2 or 3 mins after time
# - save on the 5min marks and subract 5mins.
# http://www.bom.gov.au/radar/IDR223.gif
#
# Satellite Images
# - marked 1hr intervals at 32 past each hour
# - produced at 15min (approx) past each following hour (43mins after their timestamp)
# - save at 22min past each hour mark and subract 50mins (3000secs).
# http://www.bom.gov.au/gms/IDE00135.jpg
#
# Set cron at 10min intervals on the 5min mark.
############## BEGIN DEFAULTS ##############
baseDir='/mnt/data/www/weewx/radarImages'
#baseDir='/mnt/data/www/weewx/radarImages-test'
stillSource="http://www.bom.gov.au/radar/IDR223.gif"
# Format of Still images (used in some file masking ops).
stillFormat='gif'
# Prefix for downloaded Still images, used with Timestamp
# and Format ('stillPrefix'_'timeStamp'.'stillFormat')
# to create unique filenames.
stillPrefix='bomMackayRadar'
# Prefix for composed GIF Anims, used with Timestamp and Format
# ('animPrefix'_'timeStamp'.'gif') to create unique filenames.
animPrefix='radarLoop'
# SubDir of 'baseDir' to store Stills in.
stillDir='stills'
# SubDir of 'baseDir' to store Anims in.
animDir='anims'
# Anim Loop length to generate in Hours, for me 2hrs is only
# 13 images (2*6+1), so only 12 secs long final anim.
animLength='2'
# Delay between Frames in Hundreths (1/100) of a Second.
animDelay='100'
# How many Still Images downloaded, and Anims generated per Hour,
# this will need to be synced with your cron job, it's
# used in some calcs, so placed here for adjustability.
imagesPerHour='6'
# Time Difference (in seconds) between image generation,
# and the download. The final result resolution is
# in minutes, so there is leaway built-in. Using
# seconds because it makes the math much easier.
timeVector='300'
# Anims Archive Length in Days.
animKeepDays='1'
# Stills Archive Length in Days.
stillKeepDays='2'
# Image Quality.
imgQual='75'
# Timestamp X position in Pixels (image origin = top left).
timeStampLocX='299'
# Timestamp Y position in Pixels.
timeStampLocY='34'
# Timestamp Font.
timeStampFont='Helvetica-Bold'
# Timestamp Font Size.
timeStampFontSize='20'
# Timestamp Colour.
timeStampColor='darkgreen'
# Location Hilight X position in Pixels.
locationX='254'
# Location Hilight Y position in Pixels.
locationY='320'
# Radius of Location Hilight in Pixels.
locationRadius='4'
# Location Hilight Colour.
locationColor='darkred'
# Crop image (Xsize)x(Ysize)+(Xoffset)+(Yoffset),
# leave blank ('') for no cropping.
cropXY='512x552+6+6'
############### END DEFAULTS ###############
Satellite Config:
# Radar Images
# - maked in 10min intervals
# - produced 2 or 3 mins after time
# - save on the 5min marks and subract 5mins.
# http://www.bom.gov.au/radar/IDR223.gif
#
# Satellite Images
# - marked 1hr intervals at 32 past each hour
# - produced at 15min (approx) past each following hour (43mins after their timestamp)
# - save at 22min past each hour mark and subract 50mins (3000secs).
# http://www.bom.gov.au/gms/IDE00135.jpg
#
# Set cron at 1hr intervals on the 22min mark.
############## BEGIN DEFAULTS ##############
baseDir='/mnt/data/www/weewx/satelliteImages'
#baseDir='/mnt/data/www/weewx/satelliteImages-test'
stillSource="http://www.bom.gov.au/gms/IDE00135.jpg"
# Format of Still images (used in some file masking ops).
stillFormat='jpg'
# Prefix for downloaded Still images, used with Timestamp
# and Format ('stillPrefix'_'timeStamp'.'stillFormat')
# to create unique filenames.
stillPrefix='bomMackaySatellite'
# Prefix for composed GIF Anims, used with Timestamp and Format
# ('animPrefix'_'timeStamp'.'gif') to create unique filenames.
animPrefix='satelliteLoop'
# SubDir of 'baseDir' to store Stills in.
stillDir='stills'
# SubDir of 'baseDir' to store Anims in.
animDir='anims'
# Anim Loop length to generate in Hours, for me 24hrs is only
# 25 images (24*1+1), so only 12 secs long final anim.
animLength='24'
# Delay between Frames in Hundreths (1/100) of a Second.
animDelay='50'
# How many Still Images downloaded, and Anims generated per Hour,
# this will need to be synced with your cron job, it's
# used in some calcs, so placed here for adjustability.
imagesPerHour='1'
# Time Difference (in seconds) between image generation,
# and the download. The final result resolution is
# in minutes, so there is leaway built-in. Using
# seconds because it makes the math much easier.
timeVector='3000'
# Anims Archive Length in Days.
animKeepDays='3'
# Stills Archive Length in Days.
stillKeepDays='6'
# Image Quality.
imgQual='75'
#588 x 470
# Timestamp X position in Pixels (image origin = top left).
timeStampLocX='410'
# Timestamp Y position in Pixels.
timeStampLocY='444'
# Timestamp Font.
timeStampFont='Helvetica-Bold'
# Timestamp Font Size.
timeStampFontSize='20'
# Timestamp Colour.
timeStampColor='wheat'
# Location Hilight X position in Pixels.
locationX='442'
# Location Hilight Y position in Pixels.
locationY='176'
# Radius of Location Hilight in Pixels.
locationRadius='4'
# Location Hilight Colour.
locationColor='wheat'
# Crop image (Xsize)x(Ysize)+(Xoffset)+(Yoffset),
# leave blank ('') for no cropping.
cropXY=''
############### END DEFAULTS ###############
Crontab:
# BOM Radar Looper
5,15,25,35,45,55 * * * * /home/XXXX/.bin/bomAnimGenerator.sh /home/XXXXX/.bin/bomRadarAnim.cfg
# BOM Satellite Looper
22 * * * * /home/XXXXX/.bin/bomAnimGenerator.sh /home/XXXXX/.bin/bomSatelliteAnim.cfg