第一个问题似乎发生了,因为当convert
接收到一个列表时,它将使用指定为输出文件名的最后一个文件。所有新文件都以最后一个文件命名,该文件本身保持不变(这不太可能是您想要或期望的,但这可能比您的文件被意外覆盖要好)。
When there is only one file in the directory (so your glob expands to the one file), convert
complains about lack of defined images because it expects at least one input file and an output file name to be specified. The position you are using for your glob is the output filename position, so convert
is complaining about the lack of an input file in your second image.
For more reliable results you should specify the input and output files:
convert input-file.jpg -crop 599x500+147+200 new-file.jpg
If the name is long, you should be able to use tab completion (type the first few characters and then press tab to have the shell finish the name) for both input file and output file (that is, it's working fine for me).
对于批处理,您可以使用 shell 对每个文件运行一次命令,并使用一些字符串操作来构造新名称,因此新文件具有合理的名称,例如:
for f in *.jpg; do
echo convert "$f" -crop 599x500+147+200 "${f/.jpg/-cropped.jpg}"
done
在echo
第二行中,这显示了新名称的含义。如果新名称看起来正确,您可以删除echo
并再次运行命令以实际裁剪图像。
将新文件放入新目录可能更容易,特别是如果您的文件名具有不同的扩展名...
mkdir cropped
for f in *.jpg *.png; do
echo convert "$f" -crop 599x500+147+200 cropped/"$f"
done
同样,您需要先删除,echo
然后才能执行任何操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句