Using imagemagick, I'm looking to add an expanded background color to an image. My source looks like this:
And this is the desired output (the background color will be white, but this is for clarity):
Step 1 seems to be filling the background with my desired color, but I can't find a way to remove the background outside the shape. This will also be a problem if the source image contains any of the desired background color already (because it will be made transparent).
Ideas?
It is not perfect but should do the job:
convert ( in.png -resize 200% -flatten -negate -morphology Dilate Disk:20 \
-fuzz 90% -fill none -draw "matte 0,0 floodfill" -fill green \
-colorize 100% -resize 50% ) in.png -composite out.png