From cd5c11f0677c753ec3c2fd15d0c293dafeed35dd Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Fri, 6 Oct 2023 23:13:52 -0400 Subject: [PATCH] Add support for "dup" label --- fgen.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/fgen.sh b/fgen.sh index 1e92b1e..d60da59 100755 --- a/fgen.sh +++ b/fgen.sh @@ -79,6 +79,22 @@ function get_group_id() echo "${group}" } +# Get duplicate from. Ex: "label:dup1-7 planXYZ,geometry..." will return 1 +# Arg1: line +function get_dup_from() +{ + dup=$(echo "${1}" | grep -e "label:dup.*" | ${SED} "s/.*label:dup\([0-9]\+\)-.*,geometry.*/\1/g") + echo "${dup}" +} + +# Get duplicate to. Ex: "label:dup1-7 planXYZ,geometry..." will return 7 +# Arg1: line +function get_dup_to() +{ + dup=$(echo "${1}" | grep -e "label:dup.*" | ${SED} "s/.*label:dup[0-9]\+-\([0-9]\+\).*,geometry.*/\1/g") + echo "${dup}" +} + print_usage() { echo "${PROG_NAME} -- Générateur de séquence d'images PNG à partir d'un fichier Photoshop (PSD)." @@ -192,6 +208,14 @@ if [ ${trames} -eq 1 ]; then nf=$(get_frame_id "${l}") ng=$(get_group_id "${l}") + dup_from=$(get_dup_from "${l}") + dup_to=$(get_dup_to "${l}") + + # Also indicate a new frame, but to be copied from..to: + if [ x"${dup_from}" != x"" ]; then + nf=${dup_from} + fi + # Only change group if ng is set... if [ x"${ng}" != x"" ]; then if which ffmpeg 1> /dev/null 2>&1; then @@ -244,6 +268,19 @@ if [ ${trames} -eq 1 ]; then ${dest}/${group}-f${nf}.png fi + if [ x"${dup_from}" != x"" ]; then + log_dbg " dup from: ${dup_from}" + log_dbg " dup to: ${dup_to}" + + dup_start=$((${dup_from} + 1)) + for w in $(seq ${dup_start} ${dup_to}); do + log_dbg "New frame ID: ${w} (duplicate)" + + # Use symlink??? + cp ${dest}/${group}-f${nf}.png ${dest}/${group}-f${w}.png + done + fi + files="" oldnf="${nf}" fi -- 2.20.1