Remove bashisms in apng2webp and allow for images with >100 frames
This commit is contained in:
parent
43809f8332
commit
99d550870e
@ -14,37 +14,37 @@ if [[ ${#o_help} -ne 0 || ! -v 2 ]]; then
|
||||
"<INPUT FILE> <OUTPUT FILE>"
|
||||
return ${ret}
|
||||
fi
|
||||
local input="$(realpath "${1}")"
|
||||
local output="$(realpath "${2}")"
|
||||
local input=$(realpath ${1})
|
||||
local output=$(realpath ${2})
|
||||
|
||||
local tmpdir=$(mktemp --directory --suffix='.apng2webp')
|
||||
pushd ${tmpdir}
|
||||
|
||||
mkdir -p apngdis
|
||||
pushd apngdis
|
||||
cp "${input}" "input.png"
|
||||
apngdis "input.png"
|
||||
cp ${input} input.png
|
||||
apngdis input.png
|
||||
popd
|
||||
|
||||
counter=1
|
||||
for file in apngdis/apngframe*.png; do
|
||||
cwebp -lossless -q 100 "${file}" -o "$(printf "%02d" ${counter}).webp"
|
||||
cwebp -lossless -q 100 ${file} -o $(printf "%03d.webp" ${counter})
|
||||
counter=$(( counter+1 ))
|
||||
done
|
||||
|
||||
local -a webpmux_options=()
|
||||
local -i counter=1
|
||||
for file in apngdis/apngframe*.txt; do
|
||||
local delay=$(grep -Po '=\d+/' "${file}")
|
||||
local delay=$(grep -Po '=\d+/' ${file})
|
||||
delay=${delay:1:-1}
|
||||
[[ ${#o_delay} -eq 2 ]] && delay=${o_delay[2]}
|
||||
|
||||
webpmux_options+=(-frame $(printf "%02d.webp" ${counter}) +${delay}+0+0+0-b)
|
||||
webpmux_options+=(-frame $(printf "%03d.webp" ${counter}) +${delay}+0+0+0-b)
|
||||
counter+=1
|
||||
done
|
||||
|
||||
# shellcheck disable=2086
|
||||
webpmux ${webpmux_options} -o "${output}"
|
||||
webpmux ${webpmux_options} -o ${output}
|
||||
|
||||
popd
|
||||
rm -r ${tmpdir}
|
||||
|
Loading…
x
Reference in New Issue
Block a user