Home

Rounding Image Corners with ImageMagick

By Joel Dare - Written February 15, 2022

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

Build your next site in pure HTML and CSS

Want to build your next site in pure HTML and CSS? Join the free Five-Day Neat Starter Email Course and build a lean, production-ready page before Friday.

Email Me the Crash Course


JoelDare.com © Dare Companies Dotcom LLC

Terms - Privacy