您如何使用antotate'用蒙太奇'或在图像目录上使用convert的循环A管道循环,to to to to``蒙太奇?

发布于 2025-02-01 16:38:07 字数 1925 浏览 1 评论 0原文

我已经尝试了几天来编写一个脚本,该脚本从图像目录中创建一个简单的证明表。我找到标签图像的唯一脚本,我不喜欢。我想按标记在图像本身上, ...

我无法使用Annotate而不是标签带有montage,并且找不到在线示例。那将是理想的。如果有人知道如何实施它,我会更喜欢它。

到目前为止,我要做的是首先ressAnnotate将图像放入单独的目录中,然后使用montage创建证明表。这有效,但缺点是制作有损副本的有损副本,并要求将文件写入目录。

我试图将转换的输出输送到montage,但没有成功。那将是第二好的解决方案。如果有人知道该怎么做,那将非常有帮助。

这有效,但是……:

d="<path to image directory>"
dirname=`basename "$d"`
echo $dirname
parent=`dirname "$d"`
echo $parent
parentdir=`basename "$parent"`
echo $parentdir
cd "$d"
if [ -f "$parentdir-$dirname proof sheet.jpg" ]
then
    rm "$parentdir-$dirname proof sheet.jpg"
fi
tilenum=5
spacing=1
scrw=$((1920-(tilenum*spacing+spacing)))
imgw=$(($scrw/$tilenum))
echo $imgw
if [ ! -d rszannot ]
then
    mkdir rszannot
else
    rm rszannot/*
fi
shopt -s nullglob # prevents errors for extensions not found
shopt -s nocaseglob # case insensitive args
for f in "${arg}"*.{jpg,jpeg,png,gif}
do
    fn=$(basename "${f%.*}")
    convert -verbose "$f" \
    -define jpeg:size=${imgw}x \
    -quality 100 \
    -resize ${imgw}x \
    -gravity south \
    -pointsize 20 \
    -stroke '#000C' -strokewidth 2 -annotate 0 '%f' \
    -stroke  none   -fill white    -annotate 0 '%f' \
    "rszannot/$fn-${imgw}x.jpg"
done
cd rszannot
montage -verbose \
-quality 100 \
-background black \
-geometry +${spacing}+${spacing} \
-tile ${tilenum}x \
*.jpg \
"../$parentdir-$dirname proof sheet.jpg"
open "../$parentdir-$dirname proof sheet.jpg"
shopt -u nocaseglob
shopt -u nullglob

“证明表”

I have been trying for days to write a script that creates a simple proof sheet from a directory of images. The only scripts I found label the images, which I don't like. I wanted to annotate them as per Labeling on top of the Image itself....

I was unable to use annotate rather than label with montage and could find no examples online. That would be ideal. If someone knows how to implement that, I would prefer it.

What I did so far is to first resize and annotate the images into a separate directory and then create the proof sheet using montage. That works but has the disadvantage of making lossy copies of lossy copies and requiring writing files to a directory.

I tried to pipe the output of the convert for loop to montage but didn't succeed. That would be the second best solution. If anyone knows how to do that, that would be very helpful.

This works but…:

d="<path to image directory>"
dirname=`basename "$d"`
echo $dirname
parent=`dirname "$d"`
echo $parent
parentdir=`basename "$parent"`
echo $parentdir
cd "$d"
if [ -f "$parentdir-$dirname proof sheet.jpg" ]
then
    rm "$parentdir-$dirname proof sheet.jpg"
fi
tilenum=5
spacing=1
scrw=$((1920-(tilenum*spacing+spacing)))
imgw=$(($scrw/$tilenum))
echo $imgw
if [ ! -d rszannot ]
then
    mkdir rszannot
else
    rm rszannot/*
fi
shopt -s nullglob # prevents errors for extensions not found
shopt -s nocaseglob # case insensitive args
for f in "${arg}"*.{jpg,jpeg,png,gif}
do
    fn=$(basename "${f%.*}")
    convert -verbose "$f" \
    -define jpeg:size=${imgw}x \
    -quality 100 \
    -resize ${imgw}x \
    -gravity south \
    -pointsize 20 \
    -stroke '#000C' -strokewidth 2 -annotate 0 '%f' \
    -stroke  none   -fill white    -annotate 0 '%f' \
    "rszannot/$fn-${imgw}x.jpg"
done
cd rszannot
montage -verbose \
-quality 100 \
-background black \
-geometry +${spacing}+${spacing} \
-tile ${tilenum}x \
*.jpg \
"../$parentdir-$dirname proof sheet.jpg"
open "../$parentdir-$dirname proof sheet.jpg"
shopt -u nocaseglob
shopt -u nullglob

proof sheet

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光是把杀猪刀 2025-02-08 16:38:07

您可以在子外壳中调整和注释所有图像,然后保存到Miff:然后将其用在Unix ImageMagick中的蒙太奇。这是一个示例:

list="lena.jpg barn.jpg mandril3.jpg monet2.jpg zelda1.jpg redhat.jpg"
( 
for img in $list; do
echo >&2 "$img"
convert $img -resize "100x100^" -extent 100x100 \
-font helvetica -pointsize 14 -fill white \
-gravity south -annotate +0+5 "%f" \
miff:-
done
) | montage - -tile 3x2 -geometry +0+0 result.png

“在此处输入图像描述”

You can resize and annotate all your images in a sub shell and save to miff:, then pipe that to montage in Unix Imagemagick. Here is an example:

list="lena.jpg barn.jpg mandril3.jpg monet2.jpg zelda1.jpg redhat.jpg"
( 
for img in $list; do
echo >&2 "$img"
convert $img -resize "100x100^" -extent 100x100 \
-font helvetica -pointsize 14 -fill white \
-gravity south -annotate +0+5 "%f" \
miff:-
done
) | montage - -tile 3x2 -geometry +0+0 result.png

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文