Joel Dare

Rounding Image Corners with ImageMagick

Some instructions on how to round the corners of an image to make it a little softer. If you’re showing the image in HTML you can apply a CSS effect like border-radius, but this modifies the original image.

Create a Mask

First, create a mask that’s the same size of the image using the command below. Notice that the roundrectangle command is zero based so the size is one pixel smaller than the image size.

convert -size 664x104 xc:none -draw "roundrectangle 0,0,663,103,10,10" mask.png

Mask the Image

Now use that image as a mask on the original image to create the new rounded image.

convert original.png -matte mask.png -compose DstIn -composite rounded.png

Written by Joel Dare on February 15, 2022