我该如何结合这些命令在ImageMagick中实现圆形裁剪?
这个命令可以实现:
convert -size 200x200 xc:none -fill samia.jpg -draw "circle 100,100 100,1" circle_thumb.png
上述代码将拍摄一张照片,并在其上制作圆形裁剪,但该裁剪基于照片的左上角而不是中心点。此命令也可用于裁剪:
convert *.jpg -resize 200x200^ -gravity Center -crop 200x200+0+0 +repage out.png
上述代码将根据图像中心制作一个正方形切割图像。我的目标是:编写一个命令,接受图片作为输入并基于图片中心而非左上角进行圆形裁剪。请问有哪位熟悉IM技术的大佬能帮我解决这个问题吗?Vesa,Ubuntu 15.10更新:我尝试了Mark Setchell的解决方案,但收到以下错误消息:
axx@axx-VPCEA3S1E:~/Desktop/circular-crop$ magick samia.png \( +clone -threshold 101% -fill white -draw 'circle %[fx:int(w/2)],%[fx:int(h/2)] %[fx:int(w/2)],%[fx:80+int(h/2)]' \) -channel-fx '| gray=>alpha' circle.png
magick: no decode delegate for this image format `PNG' @ error/constitute.c/ReadImage/509.
magick: no image to apply a property "%w" @ warning/property.c/GetMagickPropertyLetter/2561.
magick: unknown image property "%w" @ warning/property.c/InterpretImageProperties/3499.
magick: no image to apply a property "%h" @ warning/property.c/GetMagickPropertyLetter/2449.
magick: unknown image property "%h" @ warning/property.c/InterpretImageProperties/3499.
magick: no image to apply a property "%m" @ warning/property.c/GetMagickPropertyLetter/2480.
magick: unknown image property "%m" @ warning/property.c/InterpretImageProperties/3499.
axx@axx-VPCEA3S1E:~/Desktop/circular-crop$
100 100 100 1
是什么意思?我正在考虑裁剪一个半径为r
,中心点为(x,y)
的圆形。 - user14554732x y w z
的意思是:以x,y
为圆心,经过w,z
的点画一个圆。因此,100 100 100 1
是一个以200x200
正方形中心为圆心,半径为99的圆。为什么他们不直接用三个数字x,y,r
呢,我也不知道... - undefined