#!/usr/bin/env zsh # Output commands to generate animated images from files setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL zmodload zsh/zutil local -a o_help=() local -a o_delay=() local -a o_blend=() zparseopts -D -K -- h=o_help -help=o_help -delay:=o_delay -blend=o_blend if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then local ret=$(( ${#o_help} ^ 1 )) print -u $(( 1 + ${ret} )) \ "usage: ${0} [-h|--help] [--delay MILLISECONDS] [--blend]" "" return ${ret} fi local delay=100 [[ ${#o_delay} -eq 2 ]] && delay=${o_delay[2]} local blend="-b" [[ ${#o_help} -ne 0 ]] && blend="+b" local -a cmd if [[ ${1##*.} == "webp" ]]; then cmd=(webpmux -o output.webp) for file in ${@}; do cmd+=(-frame ${file} +${delay}+0+0+0${blend}) done elif [[ ${1##*.} == "png" ]]; then cmd=(apngasm --output output.png) for file in ${@}; do cmd+=(${file} ${delay}) done else print -u 2 "file format not supported" return 1 fi if [[ -o INTERACTIVE ]]; then print -z "" ${cmd} else print "" ${cmd} fi