From 75efbf87ea3f7b4ba4a557ba016ff8cc4a4c703f Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Fri, 6 Oct 2023 16:15:55 -0400 Subject: [PATCH] Extract scene number in IM identify tool --- fgen.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/fgen.sh b/fgen.sh index ea04217..8de4036 100755 --- a/fgen.sh +++ b/fgen.sh @@ -43,13 +43,13 @@ function get_size() # Arg1: layer function get_pos() { - cat ${layers} | grep "${1}" | ${SED} "s/.*geometry:[0-9]\+x[0-9]\+\(+[0-9]\+[0-9]\+\)/\1/g" + cat ${layers} | grep "${1}" | ${SED} "s/.*geometry:[0-9]\+x[0-9]\+\(+[0-9]\++[0-9]\+\),.*/\1/g" } # Arg1: line function get_label() { - frame=$(echo "${1}" | grep -e "label:.*," | ${SED} "s/label:\(.*\),.*/\1/g") + frame=$(echo "${1}" | ${SED} "s/.*label:\(.*\),geometry.*/\1/g") if [ x"${frame}" = x"" ]; then echo "" @@ -63,7 +63,7 @@ function get_label() # Arg1: line function get_frame_id() { - frame=$(echo "${1}" | grep -e "label:[0-9]\+," | ${SED} "s/label:\([0-9]\+\),.*/\1/g") + frame=$(echo "${1}" | grep -e "label:[0-9]\+," | ${SED} "s/.*label:\([0-9]\+\),.*/\1/g") if [ x"${frame}" = x"" ]; then echo "" @@ -72,6 +72,14 @@ function get_frame_id() fi } +# Arg1: line +function get_scene_id() +{ + local token + token=$(echo "${1}" | ${SED} "s/.*scene:\([0-9]\+\),.*/\1/g") + echo "${token}" +} + # Arg1: label function is_skip_label() { @@ -156,9 +164,10 @@ for tool in convert composite identify; do done if [ ${trames} -eq 1 ]; then - identify ${IM_OPS} -verbose -format "label:%l,geometry:%g\n" ${src} > ${layers} + # %s: scene number + identify ${IM_OPS} -verbose -format "scene:%s,label:%l,geometry:%g,\n" ${src} > ${layers} - # Ignore empty labels: + # Remove line(s) with empty label: ${SED} -i -e /label:,.*/d ${layers} # Extract global frame size: @@ -177,21 +186,17 @@ if [ ${trames} -eq 1 ]; then # Create background frame: convert -size ${size} xc:none ${dest}/background.png - # Will start at frame 2 at first loop iteration - f=1 - nf="" oldnf="" files="" while read l; do - f=$((${f} + 1)) - + scene=$(get_scene_id "${l}") label=$(get_label "${l}") p=$(get_pos "${l}") nf=$(get_frame_id "${l}") - log_dbg "Couche ${f}" + log_dbg "Layer ${scene}" log_dbg " nom: ${label}" log_dbg " pos: ${p}" @@ -200,7 +205,7 @@ if [ ${trames} -eq 1 ]; then continue fi - files="${files} -page ${p} ${src}[${f}]" + files="${files} -page ${p} ${src}[${scene}]" if [ x"${nf}" != x"" ]; then # Only check expected frame if oldnf is set... -- 2.20.1