我有 100 多个 png 文件,都是 500x500,我试图在 400x400 图像的中心裁剪一个圆圈,并将其保存到一个单独的 png 中,同时保持 500x500。下面的例子
有谁知道如何使用图像魔术来实现这一点并运行文件夹中的每个文件? - 谢谢
来源
期望的输出
您可以在我如何组合这些命令以在 ImageMagick 中实现循环裁剪中找到答案?
magick convert input.jpg -gravity center ( -size 480x480 xc:black -fill white -draw "circle 240 240 240 0" -alpha copy ) -compose copyopacity -composite output.png
magick input.jpg ( +clone -threshold 101% -fill white -draw "circle %[fx:int(w/2)],%[fx:int(h/2)] %[fx:int(w/2)],%[fx:int(h)]" ) -channel-fx "| gray=>alpha" output.png
magick input.jpg ( +clone -threshold 101% -fill white -draw "roundRectangle 0,0 %[fx:int(w)],%[fx:int(h)] 50,50" ) -channel-fx "| gray=>alpha" output.png
magick input.jpg ( +clone -threshold 101% -fill white -draw "roundRectangle %[fx:int((w-h)/2)],0 %[fx:int((h+w)/2)],%[fx:int(h)] 50,50" ) -channel-fx "| gray=>alpha" -trim output.png
您可以使用 mogrify 处理文件夹中的每个 (png) 图像。假设 Imagemagick 6. 只需将目录更改为文件夹并将路径添加到 mask.png 图像,它不应该在该目录中。
mogrify -alpha set -draw "image copy_opacity 0,0 0,0 'mask.png'" *.png
magick input.jpg ( +clone -threshold 101% -fill white -draw "roundRectangle 0,0 %[fx:int(w)],%[fx:int(h)] 50,50" ) -channel-fx “|灰色=>alpha”输出.png 不能在 Windows 中工作,magick V7。 “灰色”不被识别为内部或外部命令, 可运行的程序或批处理文件。
这可以克服吗?