Reputation: 255
Much like this question 3, im trying to achieve a fade but to a constant color rather than fade to transparent, how can the fade at all the edges, go to blue rather than to transparent? I have tried the following:
convert doge.png -alpha set -virtual-pixel transparent -background blue -channel A -morphology Distance Euclidean:1,20\! +channel _doge.png
convert doge.png -alpha set -virtual-pixel Blue -channel A -morphology Distance Euclidean:1,20\! +channel _doge.png
unsuccessfully. I also considered vignette 4 which it turns out produces very stretched ovals on my very rectangular images, making them unattractive, therefore i have a need to keep the fade to black rectangular, if i can use this fade to produce a fade to black it would suffice.
with the first command i get this, before and after:
,
The second command errs out with this error:
convert: unrecognized virtual pixel method `Blue' @ error/convert.c/ConvertImageCommand/3177.
Upvotes: 0
Views: 793
Reputation: 53154
You can do that by the following in Imagemagick 6. I create a black image and blur the edges linearly rather than by a gaussian blur. Then I use that as a mask to blend the image with a blue image to make the results.
convert doge.png \
\( -clone 0 -fill blue -colorize 100 \) \
\( -clone 0 -fill black -colorize 100 -virtual-pixel white -blur 100x65000 \) \
-compose over -composite \
result.png
You can also use a gaussian-like blur as follows:
convert doge.png \
\( -clone 0 -fill blue -colorize 100 \) \
\( -clone 0 -fill black -colorize 100 -virtual-pixel white -blur 0x50 \) \
-compose over -composite \
result2.png
Here is a smaller blur distance:
convert doge.png \
\( -clone 0 -fill blue -colorize 100 \) \
\( -clone 0 -fill black -colorize 100 -virtual-pixel white -blur 20x65000 \) \
-compose over -composite \
result3.png
If you want it more deep blue, then you can control that with the -level operator:
convert doge.png \
\( -clone 0 -fill blue -colorize 100 \) \
\( -clone 0 -fill black -colorize 100 -virtual-pixel white -blur 20x65000 -level 0x50% \) \
-compose over -composite \
result4.png
For Imagemagick 7, use magick rather than convert.
Upvotes: 2
Reputation: 5395
Several good answers have been provided above, but here's a slightly different approach. Read the input image, clone it, colorize it black, shave it some and add a blue border, make the black transparent, blur the blue border, and composite that over the original input. A command might look something like this...
convert input.png -bordercolor blue -fill black \
\( +clone -colorize 100 -shave 10 -border 10 \
-transparent black -blur 0x10 \) -composite result.png
Upvotes: 2
Reputation: 53154
A slight variation to emcconville's excellent Imagemagick answer is to keep the transparency and just flatten against blue.
convert doge.png \
-alpha set -virtual-pixel transparent -channel A -morphology Distance Euclidean:1,20\! +channel \
-background blue -compose over -flatten \
result.png
Upvotes: 2
Reputation: 24439
Your doing the morphology on the Alpha channel, but what about just the Red & Green channels.
convert doge.png -alpha set -virtual-pixel transparent -background blue \
-channel RG -morphology Distance Euclidean:1,20\! +channel _doge.png
Upvotes: 2