The nice thing about IM is so far this can all be done without writing to temporary files, with the help of command parentheses.
I have a functioning workaround (posted in the code at the bottom) which separates the color background fill color and then changes the opacity of rounded corner mask to create the same effect (since I'm not really that familiar with IM so parts are taken from useful docs examples) but the purpose of this topic is to ask if there's a way to instead allow for the final background fill to be defined as a single RGBA value while using the alpha image of the rounded corners as a kind of clipping mask. This would allow me to simplify the background color to a single variable for a script I have in mind.
A visual representation of the desired effect (the 'Goal' background is 70% opacity):
What I have so far
The generated rounded corner image (here edited to output to an external file for the sake of this topic):
Code: Select all
magick -background "#FFFFFF" -fill "#FFFFFF" -font "Segoe-UI-Semibold" -pointsize "15" label:"Text String" -gravity southeast -splice 6x4 -gravity northwest -splice 6x2 ^( +clone -alpha extract -draw " fill black polygon 0,0 0,2 2,0 fill white circle 2,2 2,0" ^( +clone -flip ^) -compose Multiply -composite ^( +clone -flop ^) -compose Multiply -composite ^) -alpha off -compose CopyOpacity -composite -channel a -evaluate divide 1 output.png
Code: Select all
magick -background "#3399FF" -fill "#F26322" -font "Segoe-UI-Semibold" -pointsize "15" label:"Text String" -gravity southeast -splice 6x4 -gravity northwest -splice 6x2 ^( -background "#FFFFFF" -fill "#FFFFFF" -font "Segoe-UI-Semibold" -pointsize "15" label:"Text String" -gravity southeast -splice 6x4 -gravity northwest -splice 6x2 ^( +clone -alpha extract -draw " fill black polygon 0,0 0,2 2,0 fill white circle 2,2 2,0" ^( +clone -flip ^) -compose Multiply -composite ^( +clone -flop ^) -compose Multiply -composite ^) -alpha off -compose CopyOpacity -composite -channel a -evaluate divide 1.42 ^) -compose CopyOpacity -composite output.png