If you’ve seen my other tutorials/note-drops on receiving GOES imagery and how to delete all the extra GOES files you might also be interested in generating an animated gif/movie of your files.

Obviously, this is based on the excellent work by US Radio Guy and his awesome scripts for generating all sorts of image types from what you receive from GOES satellites. I’ve just modified these to be for Linux instead of Windows.

Now, because I’m running this all on an Odroid, this is a two part thing. I receive all the images, generate the smaller images, and generate the watermarked images on the odroid, then zip them up, and download them manually over SCP from my Odroid to my main system, which is also running Linux.

So, let’s start this out.

First you’re going to want to create your image for the overlay. I used 500x100 as a size, and saved it to my goes_stuff directory that you have if you followed my other tutorial. After SCP’ing over to my radio odroid I ran this;

    $ mv ~/overlay_customlut_500x100.png ~/goes_stuff/overlay_customlut_500x100.png 

On the Odroid, you want to install imagemagick and then create the script

    $ sudo apt-get install imagemagick
    $ cd /home/radio 
    $ nano goes_create_images.sh 

Then, paste this in. note - You might have to change the paths for the web directory, and the home directory depending on your setup. You may need to change the path to your shell. I’m using ZSH and this works for me to make the script run with BASH.

    #!/usr/bin/bash 
    # get the date today 
    date=$(date '+%Y-%m-%d')
    current_time=$(date +"%H_%M_%S")
    # set your home directory, note there is no trailing slash on the directory
    homedir="/home/radio"
    overlay_image="/home/radio/goes_stuff/overlay_customlut_500x100.png"
    echo " " 
    echo ">>> PREPARE GOES IMAGES FOR ANIMATION"
    echo " "
    echo -n " Step 1 - Reduce File Sizes: "
    mkdir /tmp/autoresize
    for i in `find /var/www/html/goes/goes16/fd/CUSTOMLUT/*/ -name "*.jpg" -type f`; do 
            cp $i /tmp/autoresize/
            mogrify -path "/tmp/autoresize/" -filter Triangle -define filter:support=2 -thumbnail 2000 -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip $i
    done 
    echo "Done!"

    echo -n " Step 2 - Add Watermark to resized files: "
    mkdir /tmp/autoresize_watermarked
    mogrify -path "/tmp/autoresize_watermarked/" -format jpg -gravity southeast -draw "image over 30,30 0,0 '$overlay_image'" "/tmp/autoresize/*.jpg"
    echo "Done!" 

    echo -n " Step 3 - Zipping up the files: " 
    tar Pczf $homedir/$date-$current_time-resize.tgz /tmp/autoresize_watermarked
    echo "Done!" 

    echo -n " Step 4 - Remove Temporary Files: " 
    rm -rf /tmp/autoresize/
    rm -rf /tmp/autoresize_watermarked/
    echo "Done!"
    echo " " 
    echo " You can now SCP or FTP your file to your local computer for furthur processing"
    echo " "

Then, make the script executable, and, run it. Note this may take an hour or more to run, depending on how many days of images you have stored.

    $ chmod +x goes_create_images.sh 
    $ ./goes_create_images.sh 

Then, once the script runs, you want to scp or ftp to your server. Personally I use Filezilla and just login as the radio user using my pre-existing ssh key so it’s easy and I download the file

    2023-02-26-02_20_15-resize.tgz

Then, I delete that file off the radio server so I don’t forget later.

    $ rm 2023-02-26-02_20_15-resize.tgz

Now, over on my main desktop computer where I downloaded the file using FileZilla I continue the operation to generate the animated image and, movie file.

    $ cd ~
    $ mv ~/Downloads/2023-02-26-02_20_15-resize.tgz ~/resize.tgz
    $ mkdir ~/autoresize && tar xzvf resize.tgz --strip-components=2 -C ./autoresize
    $ rm ~/resize.tgz 

Here, you might want to use a file manager to view the thumbnails of the directory ~/autoresize to see if any images are pixelated or don’t appear properly and delete them.

Then, you’ll want to create the script to automate gif and mp4 generation.

    $ nano ~/goes_animation_generate.sh 

Now, you’ll paste this into it. Again, this is setting the shell as BASH so it runs properly. You might have to change that path or your home directory path as well.

    #!/bin/sh
    # get the date and time
    date=$(date '+%Y-%m-%d')
    current_time=$(date +"%H_%M_%S")
    # note there's no trailing slash on the home directory
    home_dir="/home/username"

    echo " " 
    echo ">>> GENERATE THE ANIMATED GIF / MP4"
    echo " "

    # if directory exists, delete it and then create it, hacky but works. 
    rm -rf $home_dir/goes_final
    mkdir $home_dir/goes_final

    echo -n "Step 5 - Generate the GIF animated image at full size: "
    convert -loop 0 -delay 20 "$home_dir/autoresize/GOES16_*.jpg" "$home_dir/goes_final/output-orig.gif"
    echo "Done!"

    echo -n "Step 6 - Convert final GIF animation image to 800 pixels: "
    convert -resize 800x800 -loop 0 -delay 20 "$home_dir/autoresize/GOES16_*.jpg" "$home_dir/goes_final/output-800px.gif"
    echo "Done!"

    echo -n "Step 7 - Convert final GIF animation image to 320 pixels: "
    convert -resize 320x320 -loop 0 -delay 20 "$home_dir/autoresize/GOES16_*.jpg" "$home_dir/goes_final/output-320px.gif"
    echo "Done!"

    echo -n "Step 8 - Generate MP4 movie file at full size: "
    ffmpeg -loglevel quiet -i "$home_dir/goes_final/output-orig.gif" -filter "minterpolate='mi_mode=blend'" -c:v libx264 -pix_fmt yuv420p "$home_dir/goes_final/output-orig.mp4"
    echo "Done!"

    echo -n "Step 9 - Convert final MP4 movie file to 800 pixels: "
    ffmpeg -loglevel quiet -i "$home_dir/goes_final/output-orig.mp4" -filter "scale=800:-1" -c:v libx264 -pix_fmt yuv420p "$home_dir/goes_final/output-800px.mp4"
    echo "Done!"

    echo -n "Step 10 - Convert final MP4 movie file to 320 pixels: "
    ffmpeg -loglevel quiet -i "$home_dir/goes_final/output-orig.mp4" -filter "scale=320:-1" -c:v libx264 -pix_fmt yuv420p "$home_dir/goes_final/output-320px.mp4"
    echo "Done!"

    echo -n "Step 11 - Renaming Files: "
    # GIFs 
    mv $home_dir/goes_final/output-orig.gif $home_dir/goes_final/$date-$current_time-orig.gif
    mv $home_dir/goes_final/output-800px.gif $home_dir/goes_final/$date-$current_time-800px.gif
    mv $home_dir/goes_final/output-320px.gif $home_dir/goes_final/$date-$current_time-320px.gif
    # MP4s
    mv $home_dir/goes_final/output-orig.mp4 $home_dir/goes_final/$date-$current_time-orig.mp4
    mv $home_dir/goes_final/output-800px.mp4 $home_dir/goes_final/$date-$current_time-800px.mp4
    mv $home_dir/goes_final/output-320px.mp4 $home_dir/goes_final/$date-$current_time-320px.mp4
    echo "Done!"

    echo -n "Step 12 - Move Files to home directory: "
    mv $home_dir/goes_final/$date-$current_time-orig.gif ~
    mv $home_dir/goes_final/$date-$current_time-800px.gif ~
    mv $home_dir/goes_final/$date-$current_time-320px.gif ~
    mv $home_dir/goes_final/$date-$current_time-orig.mp4 ~
    mv $home_dir/goes_final/$date-$current_time-800px.mp4 ~
    mv $home_dir/goes_final/$date-$current_time-320px.mp4 ~
    echo "Done!" 

    echo " "
    echo "We're Done! - Your files are located at ~/$date-$current_time-*.gif and ~/$date-$current_time-*.mp4"
    echo " "

Now make it executable

    $ chmod +x ~/generate_goes_animation.sh 

Then run your script to make the animated gif at full size, 800 pixels, and 320pixels, along with the corresponding mp4 movies at full size, 800 pixels, and 320 pixels.

    $ ./generate_goes_animation.sh 

Now just check out your home directory for the files generated.

    $ ls

You should have 4 files in your home directory, and the goes_final directory should be deleted.

    -rw-r--r--  1 username users   6325220 Feb 26 04:42  2023-02-26-04_39_59-320px.gif
    -rw-r--r--  1 username users   2059972 Feb 26 04:43  2023-02-26-04_39_59-320px.mp4
    -rw-r--r--  1 username users  35667862 Feb 26 04:42  2023-02-26-04_39_59-800px.gif
    -rw-r--r--  1 username users  12687219 Feb 26 04:43  2023-02-26-04_39_59-800px.mp4
    -rw-r--r--  1 username users 202135486 Feb 26 04:41  2023-02-26-04_39_59-orig.gif
    -rw-r--r--  1 username users  81030312 Feb 26 04:43  2023-02-26-04_39_59-orig.mp4

Congrats, you’re able to use these images or movies, or, modify the scripts to the sizes you need/want!

Hope this helps someone else.