#!/usr/bin/env bash
set -Eeuo pipefail
trap 'declare rc=$?;
>&2 echo "Unexpected error executing $BASH_COMMAND at ${BASH_SOURCE[0]} line $LINENO"; exit $rc' ERR
main () {
declare in="${1:-image.png}"
declare smol="${in%.*}-smol.gif"
declare out="${in%.*}-triggered.gif"
declare geometry=48x48 delay=3
convert -sample "$geometry" "$in" "$smol"
convert -loop 0 -delay "$delay" -size "$geometry" "$smol" \
-page "-2-0" -dispose "Background" "$smol" \
-page "+2-0" -dispose "Background" "$smol" \
-page "-3+1" -dispose "Background" "$smol" \
"$out"
echo "$out"
}
main "$@"