diff --git a/.config/zsh/completions/_animoji-command b/.config/zsh/completions/_animoji-command index 3b7d43e..4345d9c 100644 --- a/.config/zsh/completions/_animoji-command +++ b/.config/zsh/completions/_animoji-command @@ -4,6 +4,7 @@ _arguments '-h[short help text]' \ '--help[short help text]' \ '--delay[milliseconds to show each frame]:milliseconds' \ '--blend[enable blending (only WebP)]' \ + '--reverse[append all images again, in reverse]' \ '*:input files:_files' # Local Variables: diff --git a/.config/zsh/functions/animoji-command b/.config/zsh/functions/animoji-command index b8aa401..bf79a7f 100755 --- a/.config/zsh/functions/animoji-command +++ b/.config/zsh/functions/animoji-command @@ -7,18 +7,21 @@ 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 +local -a o_reverse=() +zparseopts -D -K -- h=o_help -help=o_help \ + -delay:=o_delay -blend=o_blend -reverse=o_reverse if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then local ret=$(( ${#o_help} ^ 1 )) print -u $(( 1 + ${ret} )) \ - "usage: ${0} [-h|--help] [--delay MILLISECONDS] [--blend]" "" + "usage: ${0} [-h|--help] [--delay MILLISECONDS] [--blend] [--reverse]" \ + "" return ${ret} fi local delay=100 [[ ${#o_delay} -eq 2 ]] && delay=${o_delay[2]} local blend="-b" -[[ ${#o_help} -ne 0 ]] && blend="+b" +[[ ${#o_blend} -ne 0 ]] && blend="+b" local -a cmd if [[ ${1##*.} == "webp" ]]; then @@ -26,11 +29,25 @@ if [[ ${1##*.} == "webp" ]]; then for file in ${@}; do cmd+=(-frame ${file} +${delay}+0+0+0${blend}) done + if [[ ${#o_reverse} -ne 0 ]]; then + cmd[-1]=+$((${delay} * 2))+0+0+0${blend} + cmd[6]=+$((${delay} * 2))+0+0+0${blend} + for file in ${(Oa)@:2:-1}; do + cmd+=(-frame ${file} +${delay}+0+0+0${blend}) + done + fi elif [[ ${1##*.} == "png" ]]; then cmd=(apngasm --output output.png) for file in ${@}; do cmd+=(${file} ${delay}) done + if [[ ${#o_reverse} -ne 0 ]]; then + cmd[-1]=$((${delay} * 2)) + cmd[5]=$((${delay} * 2)) + for file in ${(Oa)@:2:-1}; do + cmd+=(${file} ${delay}) + done + fi else print -u 2 "file format not supported" return 1