1
0
Fork 0

add animoji-command

This commit is contained in:
tastytea 2022-06-15 02:02:12 +02:00
parent 8285a5eac8
commit 2cee8d2120
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,11 @@
#compdef animoji-command
_arguments '-h[short help text]' \
'--help[short help text]' \
'--delay[milliseconds to show each frame]:milliseconds' \
'--blend[enable blending (only WebP)]' \
'*:input files:_files'
# Local Variables:
# mode: shell-script
# End:

View File

@ -0,0 +1,42 @@
#!/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]" "<FILES>"
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