ImageMagick,Bash 用于标记注释和图像序列号的脚本

ImageMagick, Bash script to label with comment and image sequence number

我想要一套70张照片的联系表。

而且,每张照片都会有类似这个标签:

n Comment

其中 n 表示图像编号。

我的 Bash 脚本正确显示了评论。图片序号我很纳闷

#!/bin/bash 

/usr/bin/montage \
  -monitor  \
  -tile '3X3' \
  -label [useless attempts to number images]  %c \
  '/tmp/*-thumb.jpg' \
  ~/Desktop/SE-%d.jpg

我尝试了各种 fx: 表达式和百分比转义结构,结果要么什么都不显示,要么数字为零 (http://www.imagemagick.org/script/fx.php, http://imagemagick.org/script/escape.php).

我会这样做,使用 MIFF 将单独标记的文件附加到输出流,然后将它们从 stdin 全部读入 montage 命令:

#!/bin/bash
i=0
for f in /tmp/*-thumb.jpg; do
  convert -label "$i Comment %f" "$f" miff:-
  ((i++))
done | montage -       \
   -frame 5            \
   -tile 3x3           \
   -geometry +10+10    \
   -background black   \
   ~/Desktop/TheAnswer.jpg

他们出来的样子是这样的: