蒙太奇不会使用文本文件中表示的字符串列表标记图像 [英] montage does not label images with list of strings represented in text file
本文介绍了蒙太奇不会使用文本文件中表示的字符串列表标记图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个目录( ./ img /
),里面有大量图片。我想用每个文件的特定标签对它们进行蒙太奇。我有一个文本文件( label.txt
),其中包含标签列表:
I have a directory (./img/
) with a large number of images in it. I want to montage them with specific label for each file. I have a text file (label.txt
) which has list of labels:
label1
label2
label3
label4
...
label1
label2
label3
label4
...
我使用此命令:
montage -label @label.txt -size 512x512 "./img/*.*[120x90]" -geometry +5+5 photo.png
但是在结果,所有图像都被 label.txt
的所有行标记!如何将它们分开,因此每个图像都会被 label.txt
的相关行标记?
But in result, all images are labeled by all lines of label.txt
! How I can separate them, so each image will be labeled by relevant line of label.txt
?
推荐答案
我更改了示例代码 / users / 6327365 / grochmal> @ grochmal 它的工作原理:
I changed sample code represented by @grochmal and it works:
#!/bin/bash
LABELS=${1:-./labels.txt}
IMAGES=""
readarray labels < "$LABELS"
i=0
echo @ is $@
#copy input argument array in InArg array:
for img in "$@"; do
InArg[$i]=$img
((i++))
done
#get dimensions of InArg array:
arraylength=${#InArg[@]}
#extract Input Image array from InArg array:
for (( i=1; i<${arraylength}; i++ ));
do
ImageArray[$i]=${InArg[$i]}
done
#create IMAGES from some elements of InArg array:
for (( i=1; i<${arraylength}; i++ ));
do
IMAGES+=" -label ${labels[i-1]} ${ImageArray[$i]}"
done
echo "IMAGES is $IMAGES"
echo montage -size 512x512 $IMAGES -font FreeMono-Bold-Oblique -pointsize 30 -geometry '120x90+5+5>' -tile 5x -frame 5 -shadow out.html
montage -size 512x512 $IMAGES -font FreeMono-Bold-Oblique -pointsize 30 -geometry '120x90+5+5>' -tile 5x -frame 5 -shadow out.html
这篇关于蒙太奇不会使用文本文件中表示的字符串列表标记图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文