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

旧巷老猫 提交于 2020-01-14 22:54:29

问题


I would like to have a set contact sheets for 70 photos.

And, each photo would have similar to this label:

n Comment

where n indicates the image number.

My Bash script correctly shows the comment. For the image sequence number I am puzzled.

#!/bin/bash 

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

I have tried various fx: expressions and percent escapes constructs with results either nothing displayed or the numeral zero (http://www.imagemagick.org/script/fx.php, http://imagemagick.org/script/escape.php).


回答1:


I would do it something like this, using a MIFF to append individually labelled files to an output stream then read them all from stdin into the montage command:

#!/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

They come out looking like this:



来源:https://stackoverflow.com/questions/28444051/imagemagick-bash-script-to-label-with-comment-and-image-sequence-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!