How do I add outline

Goal: to add outline around irregular (rounded counter?) shape

Relevant reading:

approach A

I admit I do not exactly know why it works. But it works so if that is enough for you don't let your urge to fight ignorance prevent you from using it.

magick <input-file>^
( -clone 0 -fill <color> -colorize 100  )^
( -clone 0 -alpha extract -virtual-pixel black -morphology edgein octagon )^
-compose over -composite <output-file>


magick input\rounder-corners.png^
( -clone 0 -fill #000000 -colorize 100  )^
( -clone 0 -alpha extract -virtual-pixel black -morphology edgein octagon )^
-compose over -composite output\output.png


<color> can be in fact any color so be creative:

approach B

This time we create a rounded rectangle of dimensions slightly bigger than the counter itself and then we overlay the bigger rectangle with the counter.

magick input\rounder-corners.png +antialias ^
( +clone -size %%[fx:w+6]x%%[fx:h+6] ^
canvas:transparent -delete -2 -fill black ^
-draw "roundrectangle 0,0 %%[fx:w-1],%%[fx:h-1] 18,18" ) ^
+swap -gravity center -composite output\output.png



If we didn't factor the large curvature of the external border, the results would be somewhat less eye-pleasing: