Page 1 of 1

Help with outer glow and alpha mask

Posted: 2011-11-04T11:00:32-07:00
by Greywey
Hi I have two problems. First, I'm trying to make a purple outer glow. Every time I look up "glow" its not what I'm looking for. I also tried making a larger centered purple shadow but it's not right. My second problem is that I need to make an alpha mask. Where any pixel alpha=0 is black, and everything else is white. Thanks very much for any help.

Re: Help with outer glow and alpha mask

Posted: 2011-11-04T11:37:36-07:00
by fmw42
More information about your image would be helpful or a link to your image?

Nevertheless, see http://www.imagemagick.org/Usage/fonts/ for examples of such things done to text images.

Re: Help with outer glow and alpha mask

Posted: 2011-11-04T23:13:12-07:00
by anthony
More specifically look at the Neon sign example at the very bottom
http://www.imagemagick.org/Usage/fonts/#neon

Re: Help with outer glow and alpha mask

Posted: 2011-11-05T00:07:08-07:00
by Greywey
Hi thanks very much. I actually read those articles already, they were the closest thing to what I needed. But, since they deal with fonts they were hard to use. My image is just an irregular transparent shape, a yellow star. I did manage to get my glow working thanks very much! But I'm having a hard time with the alpha mask. I need the opaque parts white over a black background with no alpha, any hints? Thanks very much.

My glow:
convert.exe a.png ( +clone -background #ff80ff -shadow 100x1+0+0 -channel A -level 0,100% -blur 0x2 ) -compose DstOver -gravity center -composite a_glow.png

My alpha mask, almost there, but the alpha channel is still there at the end?
convert.exe a.png ( +clone -background white -shadow 100x0+0+0 -channel A -level 0,100% ) -compose SrcOver -gravity center -composite a_mask.png

Re: Help with outer glow and alpha mask

Posted: 2011-11-06T19:07:05-07:00
by anthony
Give use your input image, and your results. Then let us know what you want.

You can use a cloud hosting service to store images to use. Such as 'dropbox'.

Re: Help with outer glow and alpha mask

Posted: 2011-11-07T00:23:52-07:00
by Greywey
Hi, I've uploaded "star.png" which is the source image, and I made samples of the output I need in "star_glow.png" and "star_mask.png". The mask should have no alpha. Thanks very much!

http://drillion.com/star.zip

Re: Help with outer glow and alpha mask

Posted: 2011-11-08T16:39:07-07:00
by anthony
The mask is not needed, as it is part of original image. The shadow color looks to be "DeepPink"

The technique is explained in IM Examples, Shadow Images, and more specifically, Shadow outlines
http://www.imagemagick.org/Usage/blur/#shadow_outline

The tricky part however is to realise that a shadow blur works both inward and outward.
That when overlaying the glow, the shadow is 50% transparent. You want it opaque at the very edge.
This currently needs some extra processing.

Here is the solution...

Code: Select all

  convert star.png  \
              \( +clone -background DeepPink -shadow 100x10+0+0 \
                 -channel A -level 0,50% +channel \
              \) -background none -compose DstOver -flatten \
              star_glow.png
Note I used a compose DstOver with Flatten as the shape already has enough space for the glow.
If it did not I would have just used -layers merge +repage instead.



FUTURE:
I am thinking to modify the -shadow operator so that it will accept larger values than 100% for shadow transparency. That is allow the use of -shadow 200x10+0+0 in the above to
do the correct multiplication of the alpha channel after the blur, and removing the need for extra -level operations. Currently this is not the case.

I am also thinking of treating a negative transparency that negates the shape before creating the shadow image, so as to allow the creating of 'inner shadows' for bordering shapes.

For IMv7 I am thinking of making the -shadow operator to automatically apply shadows to the given image (in the appropriate way, with enlargement -- no clone needed), while making +shadow simply create shadows (as it currently does) for DIY shadow effects. This last must be a IMv7 addition due to the simplified handling of the -shadow operator. Otherwise the change would break many scripts.

Anyone else have thoughts on these changes.

Re: Help with outer glow and alpha mask

Posted: 2011-11-08T22:28:04-07:00
by Greywey
Thanks that glow is much better!