How do I round counter corners

Goal: to round corners of a counter.

Relevant reading:

The concept is to draw a square with rounded corners and logically multiply it against source counter:

magick <input-file> +antialias ^
( +clone -size %[fx:w]x%[fx:h] canvas:transparent  -delete -2 -fill red -draw "roundrectangle 0,0 %[fx:w-1],%[fx:h-1] <radius,radius>" ) ^
+swap -gravity center -compose SrcIn -composite <output-file>

example

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

explanation:

Alternatively: https://www.imagemagick.org/Usage/thumbnails/#rounded