A LITTLE CORNER OF MY WORLD

Read a few words, keep a little time

Every moment worth recording has a light of its own.

Back to all posts
Dev notes

ImageMagick cheat sheet

My best commands for the cli tool imagemagick.

On this page
  1. Round an Image
  2. References

Round an Image

Check Image Dimensions

You can use the file command:

file ryvst.png

return for me ryvst.png: PNG image data, 650 x 520, 8-bit/color RGBA, non-interlaced.

Create the Mask (The “Round Rectangle”)

To create a rounded rectangle with 20 on each side, we use -draw. The output file is saved as mask.png.

magick -size 650x520 xc:none -draw "roundrectangle 0,0,649,519,20,20" mask.png

The roundrectangle match with your image size with -1: 649,519.

Apply the Mask to the Original Image

Now, we apply this mask to your original image (ryvst.png) and save it as rounded.png.

magick ryvst.png -alpha Set mask.png -compose DstIn -composite rounded.png

References

✿

Thank you for reading. I hope these words were useful.

Szorfein
Szorfein / Author

A little code, a little everyday life. Say hello in the guestbook. Guestbook