add animoji-command
This commit is contained in:
parent
8285a5eac8
commit
2cee8d2120
11
.config/zsh/completions/_animoji-command
Normal file
11
.config/zsh/completions/_animoji-command
Normal 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:
|
42
.config/zsh/functions/animoji-command
Executable file
42
.config/zsh/functions/animoji-command
Executable 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
|
Loading…
Reference in New Issue
Block a user