animation/stipple.sh

81 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/bash
2021-09-10 04:37:08 +00:00
if [[ "${1}" == "" ]]; then
echo "Please provide a directory of images as the first argument"
exit 1
fi
INPUT=`realpath "${1}"`
OUTPUT=`realpath "${2}"`
2021-09-09 00:53:52 +00:00
INVERT="${3}"
2021-09-10 04:37:08 +00:00
if [ ! -d "${INPUT}" ]; then
echo "Directory ${1} doesn't exist"
exit 2
2021-09-09 00:53:52 +00:00
fi
2021-09-10 04:37:08 +00:00
mkdir -p "${OUTPUT}"
WIDTH=404
HEIGHT=374
DOTSIZE=4
MAXGENERATIONS=25
2021-09-10 04:37:08 +00:00
MAXPARTICLES=400
MINDOTSIZE=0.8
LINE=0.8
FILL=true
MODE="stipple"
2021-09-10 04:37:08 +00:00
INVERT="false"
IMAGES=""
#files in dir
for png in "${INPUT}/"*.png ; do
filename=`basename "${png}"`
name=`echo "${filename}" | cut -d'.' -f1`
num=`echo "${name}" | awk -F'_' '{print $(NF)}'`
tmp=`mktemp`.png
bash white.sh "${png}" "${tmp}"
cd ~/src/stipple_gen/
if [ "${IMAGES}" == "" ]; then
part=`echo "${name}" | awk -F'_0' '{print $1}'`
IMAGES="${OUTPUT}/${part}_%06d_rendered.png"
VIDEO="${OUTPUT}/${part}.mov"
fi
bash stipple_gen.sh \
2021-09-10 04:37:08 +00:00
--display "false" \
--inputImage "${tmp}" \
--outputImage "${OUTPUT}/${name}_rendered.png" \
--outputSVG "${OUTPUT}/${name}.svg" \
--canvasWidth $WIDTH \
--canvasHeight $HEIGHT \
--dotSizeFactor $DOTSIZE \
--windowWidth $WIDTH \
--windowHeight $HEIGHT \
--maxGenerations $MAXGENERATIONS \
--minDotSize $MINDOTSIZE \
--line $LINE \
--fill $FILL \
--maxParticles $MAXPARTICLES \
2021-09-09 00:53:52 +00:00
--mode $MODE \
--invert $INVERT
2021-09-10 04:37:08 +00:00
if [[ "${INVERT}" != "" ]]; then
convert "${OUTPUT}/${name}_rendered.png" -channel RGB -negate "${OUTPUT}/${name}_rendered.png"
fi
rm "${tmp}"
cd ~/src/animation/
if [ "${MODE}" != "tsp" ]; then
opt=`mktemp`.svg
svgsort "${OUTPUT}/${name}.svg" "${opt}"
mv "${opt}" "${OUTPUT}/${name}.svg"
fi
done
2021-09-10 04:37:08 +00:00
ffmpeg -y -r 12 -f image2 -i "${IMAGES}" \
-c:v prores_ks -profile:v 3 \
"${VIDEO}"