#!/bin/bash # # slideshow_morph images # # This program attempts to use the -remote capabilities of "animate" to # generate a morphing slideshow on the fly. That is while one picture is # being displayed, the program will select (at random) and prepare the next # morph or 'transition' to use. # # Note that all images given should be all the same size! # #### # files=( "$@" ) # just save all the image filenames into an array if [ ${#files} -le 1 ]; then echo >&2 "$0: 2 or more images needed to form a slideshow!" fi # Pick a random image from that list # prev_index=`expr $RANDOM \* ${#files} / 32768` prev_image="${files[$prev_index]}" # display it in background animate -delay 100 "$prev_image" & animate_pid=$! # Set up a temporary for the transition animation with automatic cleanup # MIFF format to hole transition animation (MIFF is better than GIF) temp=/tmp/slideshow.$$.miff trap "rm -f $temp; kill $animate_pid 2>/dev/null; exit 10" 1 2 3 15 trap "rm -f $temp; exit 0" 0 # Loop forwever while :; do # pick next image next_index=`expr $RANDOM \* ${#files} / 32768` [ $next_index -eq $prev_index ] && continue # try again next_image="${files[$next_index]}" # Do you complex image transition here # The final delay is minimum display time convert "$prev_image" "$next_image" -morph 10 \ \( +clone -set delay 500 \) +swap +delete \ $temp # Has the animation been killed! if so exit kill -0 $animate_pid || exit 0 # feed transition to the animation animate -remote ephemeral:$temp & # wait for 'ephemeral:' file to have been read while [ -f $temp ]; do sleep .1; done # wait for transition time period to complete sleep 2 # replace with just the new image animate -delay 100 -remote "$next_image" & # At this point we can now take as long as needed # to generate a new transition! prev_index=$next_index prev_image="$next_image" done