Using SVG
, you can define a clipping path and then apply it when drawing a path. Can the same effect be achieved using ImageMagick
command-line options?
The only way I have been able to do it is to create the clipping path as a separate file and use -clip-mask
to apply it. Here's a contrived example that works:
convert -size 150x150 xc:none -draw "path 'M50,50 h50 v50 -h-50 z'" clip.png
convert -size 150x150 xc: -fill 'blue' -clip-mask clip.png \
-draw "path 'h150,0 l-75,75 z" image.png
What I want to do is define the clip path in the same command as the drawing, ideally somethig like this:
convert -size 150x150 xc: -fill 'blue' \
-clip-path "path 'M50,50 h50 v50 -h-50 z'" \
-draw "path 'h150,0 l-75,75 z" image.png
Which doesn't work. To try and avoid using an intermediate file, I tried using a stacked image but that doesn't seem to work as a parameter (the below did not work either):
convert -size 150x150 xc: -fill 'blue' \
-clip-mask \( -size 150x150 xc:none -draw "path 'M50,50 h50 v50 -h-50 z'" \) \
-draw "path 'h150,0 l-75,75 z" image.png
This can be done succinctly with SVG - can the ImageMagick
command-line do it?