【发布时间】:2020-12-16 19:49:33
【问题描述】:
我正在编写一个 shell 脚本来从源 PNG 输出多种图像大小和格式。该脚本运行良好并输出正确的大小和格式,但我在尝试修复的脚本末尾出现错误。 shell脚本代码如下:
convert $pic -verbose -strip \
\( +clone -quality 75 -write test-output-$today-xl.jpg -write test-output-$today-xl.webp +delete \) \
\( +clone -resize 900 -quality 75 -write test-output-$today-lg.jpg -write test-output-$today-lg.webp +delete \) \
\( +clone -resize 747 -quality 75 -write test-output-$today-md.jpg -write test-output-$today-md.webp +delete \) \
\( +clone -resize 598 -quality 75 -write test-output-$today-sm.jpg -write test-output-$today-sm.webp +delete \) \
+clone -resize 548 -quality 75 -write test-output-$today-xs.jpg -write test-output-$today-xs.webp +delete
产生这个输出:
test-input.png=>test-output-2020-12-16-xl.jpg PNG 1788x1028 1788x1028+0+0 8-bit sRGB 88171B 0.060u 0:00.065
test-input.png=>test-output-2020-12-16-xl.webp PNG 1788x1028 1788x1028+0+0 8-bit sRGB 52228B 0.180u 0:00.179
test-input.png=>test-output-2020-12-16-lg.jpg PNG 1788x1028=>900x517 900x517+0+0 8-bit sRGB 27070B 0.380u 0:00.070
test-input.png=>test-output-2020-12-16-lg.webp PNG 1788x1028=>900x517 900x517+0+0 8-bit sRGB 16648B 0.490u 0:00.070
test-input.png=>test-output-2020-12-16-md.jpg PNG 1788x1028=>747x429 747x429+0+0 8-bit sRGB 19482B 0.310u 0:00.046
test-input.png=>test-output-2020-12-16-md.webp PNG 1788x1028=>747x429 747x429+0+0 8-bit sRGB 11790B 0.350u 0:00.048
test-input.png=>test-output-2020-12-16-sm.jpg PNG 1788x1028=>598x344 598x344+0+0 8-bit sRGB 13190B 0.330u 0:00.044
test-input.png=>test-output-2020-12-16-sm.webp PNG 1788x1028=>598x344 598x344+0+0 8-bit sRGB 8134B 0.230u 0:00.033
test-input.png=>test-output-2020-12-16-xs-0.jpg[0] PNG 1788x1028=>548x315 548x315+0+0 8-bit sRGB 11719B 0.520u 0:00.073
test-input.png=>test-output-2020-12-16-xs-1.jpg[1] PNG 1788x1028=>548x315 548x315+0+0 8-bit sRGB 11719B 0.340u 0:00.047
INFO: Added frame. offset:0,0 dispose:0 blend:1
test-input.png=>test-output-2020-12-16-xs.webp[0] PNG 1788x1028=>548x315 548x315+0+0 8-bit sRGB 13732B 0.520u 0:00.075
convert: `+delete' @ error/convert.c/ConvertImageCommand/3303.
关于为什么我在使用 +delete 命令时出现错误并且还输出了最后一个 jpg 的两个版本的任何想法?
抱歉,如果这是一个简单的解决方案,我发现 imagemagick 文档对于特定问题有点难以解析。提前致谢!
【问题讨论】:
标签: shell imagemagick imagemagick-convert