gpt4 book ai didi

shell - 在 ubuntu 的 shell 脚本中调整图像大小

转载 作者:行者123 更新时间:2023-12-04 18:54:35 25 4
gpt4 key购买 nike

我有两张图片。我创建了一个 .sh 文件来操作它。首先,我为此使用for循环..

我的导演结构:-

测试
图片
文档
新图片
天使形象
测试.sh
5元素10.png
Boltonclinics5.png

现在我希望将 2 个图像与 3rd.png 合成并存储在 新形象 之后我想要 中的图像新形象 文件夹被转换为一个特定的天使。
所以我尝试使用代码

   #!/bin/bash
for f in $( ls *.png ); do
composite -gravity center $f ./doc/back.png ./newimage/new$f
done
for f in `ls ./newimage`; do

convert $f -rotate -7 ./angelimage/ang$f
done

现在我发现 for 循环可以正常工作,但是第二个循环会出现如下错误
convert: unable to open image `new-5elements10.png':  @ error/blob.c/OpenBlob/2587.
convert: unable to open file `new-5elements10.png' @ error/png.c/ReadPNGImage/3234.
convert: missing an image filename `new-5elements10.png' @ error/convert.c/ConvertImageCommand/3011.
convert: unable to open image `new-boltonclinics5.png': @ error/blob.c/OpenBlob/2587.
convert: unable to open file `new-boltonclinics5.png' @ error/png.c/ReadPNGImage/3234.
convert: missing an image filename `new-boltonclinics5.png' @ error/convert.c/ConvertImageCommand/3011.

最佳答案

不要使用 ls(1) 生成提供给命令的文件列表。简单的 glob 扩展就足够了(如下所示)。

引用您的变量以防止出现空格问题。

如果您的代码中没有任何其他逻辑错误,则应该可以:

#!/bin/bash

for f in *.png;
do
composite -gravity center "$f" ./doc/back.png "./newimage/new${f}"
done

for f in ./newimage/*;
do
convert -rotate -7 "$f" "./angelimage/ang$(basename "$f")"
done

关于shell - 在 ubuntu 的 shell 脚本中调整图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11031222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com