Search code examples
imagemagickim4java

ImageMagick: How can I cut out round from image?


I'm trying to make a round avatar out of some image. How can I cut out round from image using ImageMagick?


Solution

  • There are various ways, but the simplest is probably the undocumented "-vignette" option:

    magick CLg93.jpg -vignette 1x1 kim_vignette.jpg
    

    yields

    enter image description here

    You can deal with non-square images by applying an "offset" to the vignette geometry, for example:

    -vignette 1x1+0+50

    if the input image is a portrait that is 100 pixels taller than it is wide.