From 83623ac7221a284e5e964a9bc6d261c4b90d9217 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 17 Jun 2025 04:37:14 +0300 Subject: [PATCH] added output conflict counter -- not used yet... Signed-off-by: Alex A. Naanou --- Viewer/features/filesystem.js | 38 ++++++++++++++++++++++++++--------- misc/scripts/img2anim | 16 +++++++++------ 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/Viewer/features/filesystem.js b/Viewer/features/filesystem.js index 5fddde4c..644d6f6e 100755 --- a/Viewer/features/filesystem.js +++ b/Viewer/features/filesystem.js @@ -1836,15 +1836,20 @@ var FileSystemWriterActions = actions.Actions({ %(...)m - add text in braces if image marked %(...)b - add text in braces if image is bookmark - - %(...)C - add text in braces if there are name conflicts. +`/* + %(...)C - add text in braces if there are name conflicts + with other images in current index. NOTE: this will be added to all images. - %(...)c - add text in braces if there are name conflicts - present, but only if the current image has a - conflicting name. +*/+` %(...)c - add text in braces if there are name conflicts + present in current index, but only if the current + image has a conflicting name. %c - number in set of conflicting names (default: 0). NOTE: this is not stable and can change depending on image order. + %(...)f - same as %{...}c but for conflitcs in output directory + with pre-existing files. + %f - same as %c but for conflicts in output directory with + pre-existing files. %(...)l - image level path, level depth corresponds to ribbon number counting from the bottom @@ -1888,7 +1893,6 @@ var FileSystemWriterActions = actions.Actions({ this.images[gid] || {}, data) - name = name || pathlib.basename( data.path @@ -1952,6 +1956,7 @@ var FileSystemWriterActions = actions.Actions({ .replace(/%c/, (conflicts && conflicts[gid]) ? conflicts[gid].indexOf(gid) : 0) + .replace(/%f/, data.number ?? 0) // metadata... // XXX @@ -1969,11 +1974,15 @@ var FileSystemWriterActions = actions.Actions({ //.replace( // /%\(([^)]*)\)k/, tags.indexOf('bookmark') >= 0 ? '$1' : '') - // conflicts... - .replace( - /%\(([^)]*)\)C/, conflicts ? '$1' : '') + // in conflicts... + // XXX do we need the %(..)C here, as it is the same as setting %c? + //.replace( + // /%\(([^)]*)\)C/, conflicts ? '$1' : '') .replace( /%\(([^)]*)\)c/, (conflicts || {})[gid] ? '$1' : '') + // out conflicts... + .replace( + /%\(([^)]*)\)f/, data.number > 0 ? '$1' : '') // level... .replace( @@ -1990,6 +1999,17 @@ var FileSystemWriterActions = actions.Actions({ +(match.length + offset == str.length ? '' : '/') }) + to_ext }], + formatImageNameIter: ['- File/Format image filename (iter)', + core.doc`Same as .formatImageName(..) but returns an iterator advancing the %f value.`, + function*(format, name, data){ + var n = 0 + var prev, cur + while(true){ + cur = this.formatImageName(format, name, {__proto__: data, number: n++}) + if(cur == prev){ + break } + yield cur + prev = cur } }], // XXX should this be sync??? diff --git a/misc/scripts/img2anim b/misc/scripts/img2anim index cfbe0142..98db430c 100755 --- a/misc/scripts/img2anim +++ b/misc/scripts/img2anim @@ -6,19 +6,23 @@ FPS=${FPS:-8} -if [ $1 == "-r" ] ; then - FPS=$2 +if [ "$1" == "-r" ] ; then + FPS="$2" shift 2 fi +if ! [ -z "$1" ] ; then + PATTERN="$1" +else + PATTERN=${PATTERN:-'*.jpg'} +fi -PATTERN=${PATTERN:-'*.jpg'} +LST=($PATTERN) # generate name... -LST=($PATTERN) A=${LST[0]} -A=${A%.jpg} +A=${A%.*} B=${LST[$(( ${#LST[@]} - 1 ))]} -B=${B%.jpg} +B=${B%.*} NAME=${NAME:-${A}-${B}}