Your images can be just directly applied, to any image that is already the right size...
Code: Select all
convert thumbnail.gif -gravity center -extent 90x90 \
badge_overlay.png -composite badge.png
+
This example is now part of IM examples, Thumbnails, Overlaid Border
http://www.imagemagick.org/Usage/thumbn ... er_overlay
But that is just a simple overlay, But if you are actually wanting transparent background rather than white you will need to generate two masking images specifically a second image, that definitively divides 'inside' from 'outside'.
Ideally this should have been created when you created the original overlay image. Do you have that information? Probably not.
This is the mask I came up with... It only a guess, but it is anti-aliased and pretty close.
Code: Select all
convert -size 90x90 xc:none -draw 'circle 44.5,44 40,5' -negate badge_mask.png
Some extra blurring of the edge may be useful, but I do not think it is needed.
Other ways that could be used to generate this mask include the use of morphology, but that tends to produce a aliased (on/off) mask rather than a nice smooth edge anti-aliased version. Especially in this case were you have such a fine edge between what is 'inside' and 'outside' without any fully-opaque border to it.
Now the next problem is harder...
We need to convert the original border overlay image, so that it is a straight overlay of all highlights and shadow effects wanted. For that I need to break it in two, modify the outside into a shadow effect, then recombine..
Code: Select all
convert badge_overlay.png badge_mask.png \
\( -clone 0,1 -compose DstIn -composite -compose Over \) \
\( -clone 0,1 -compose DstOut -composite -compose Over \
-background white -flatten -negate \
-background black -alpha shape \) \
-delete 0,1 -compose Plus -composite badge_shading.png
Note that I used a -compose Plus to recombine the two images. This is the correct method of merging a 'in' and 'out' image back together. In this case an 'Over' compose would work, but the result would not be quite correct. See for another example of this usage.
http://www.imagemagick.org/Usage/compose/#dstout
and the still very raw notes about the different in Plus and Over composition Usage at
http://www.imagemagick.org/Usage/masking/#aligning
Now we have a mask, and a shading overlay image, so lets apply it to my cropped thumbnail...
Dont forget we now need alpha channel turned on on the input image!
Code: Select all
convert thumbnail.gif -alpha set -gravity center -extent 90x90 \
badge_mask.png -compose DstIn -composite \
badge_shading.png -compose Over -composite \
badge_trans_bg.png
+ +
the result is very close, with only a very slight mis-match of the circle mask to the shading mask. A bit more work on the mask position and radius (using floating point values) will make it better.
This has been added to IM_Examples, Thumbnails, Mask 'n' Paint
http://www.imagemagick.org/Usage/thumbnails/#mask_paint