Here is a drawing made to resemble an id photo of someone on transparent background. I'd like to make the bottom part soft. It must be the bottom including the sides for as long as they are touched by the green form. The -blur technique is softening the entire pattern, therefore i gave it up.
The idea would be to draw a rectangle at the bottom and fill it with gradient from black to none, (top : black, to bottom : none) and doing similarly with two small rectangles on the sides.
It seems gradient colours are not well supported on transparent background.
magick -size 120x120 xc:none -alpha set -stroke none \
-fill SpringGreen2 -draw 'rectangle 0,100 120,120' \
-fill SpringGreen3 -draw 'roundrectangle 20,60 100,120 10,10' \
-fill SpringGreen -draw 'circle 60,40 60,65' \
out.gif
here is something that looks like the sought after goal, done in inkscape using a bezier with white colour and bluring it, so here on a white web page it looks good. It must be transparent background.
EDIT: actually in the original problem the input is an image file with transparent background, not something draw by imagemagick. Therefore I'd need a solution that handles a file an input.


1 - load the input image and save it with the dedicated
MPR:method ofImageMagickfor easy easy recall2 - New empty canvas, with the dimensions of the input image:
+clone -fx whitejust a clone of any layer of the input image is fine (herealphadue to-extract alpha) and force fill with white, kind of full erase. There might other methods to do that... Thanks to the parentheses the commands will affect only the new canvas.Graycolorspace is whatCopyOpacitymethod, used later, likes3 - create a black border and blur it with
-shave 1 -bordercolor black -border 1 -blur 0x12' additionally with-level 50,100% to make sure that the edges are totally transparent. This is the 'soft edges' that is sought after4 - merge this new layer with the alpha layer of the original image.
-compositeuses the topmost two layers of the stack which here are the one created with+cloneand the alpha layer of the input image, set active with-alpha extract.multiplymethod is self descriptive5 - call back the input image with
MPR:origand+swapto get the composited at the top6 - Again
-composite... this time usingCopyOpacitymethod. This one will replace any existing alpha channel of the image with the greyscale image given (here it is the image obtained but the first-compositeoperation)This should be improvable as with this command,
magickis issuing a warning with RGB images due to the layer inGraycolorspace