Adding "outer glow" to a PNG with transparent background
Adding "outer glow" to a PNG with transparent background
Hi guys,
i have a few thousand transparent png product images
which i would need to add a background and an outer glow to. is this possible with ImageMagick and how would the convert command be?
This is what I have
This is what it should be
even better if the background could be filled with a seamless texture from an jpg file..
thanks for your help in advance
i have a few thousand transparent png product images
which i would need to add a background and an outer glow to. is this possible with ImageMagick and how would the convert command be?
This is what I have
This is what it should be
even better if the background could be filled with a seamless texture from an jpg file..
thanks for your help in advance
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adding "outer glow" to a PNG with transparent background
So why didn't you supply one? Instead, you supply an opaque example that has already been flattened against a chequer background. This means we can't experiment to work out an exact solution.Marcesh wrote:i have a few thousand transparent png product images...
But an outline solution would be: extract the alpha, and blur. This would give a "glow" mask, but might need tweaking. Composite the original over that. Then flatten against a gray background, or whatever colour or other image you want.
Please also state the version of IM you use, and platform.
snibgo's IM pages: im.snibgo.com
Re: Adding "outer glow" to a PNG with transparent background
sorry my mistake
here's the png with transparency
I'm using ImageMagick 6.8.6-9
here's the png with transparency
I'm using ImageMagick 6.8.6-9
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adding "outer glow" to a PNG with transparent background
This is very close to your desired result. Windows BAT syntax.
That gives a 42% gray background. If instead you want an image as background then ...
EDIT: My commands include "+write g.png". They are for debugging (so you can sse just the "glow"). They can be removed when you are happy with the commands.
Code: Select all
convert ^
2lllxlv.png ^
( +clone ^
-alpha extract ^
-blur 0x10 ^
-level 0,50%% ^
-background White ^
-alpha Shape ^
+write g.png ^
) ^
-compose DstOver -composite ^
-background gray(42%%) ^
-compose Over -layers flatten ^
a.png
Code: Select all
convert ^
2lllxlv.png ^
( +clone ^
-alpha extract ^
-blur 0x10 ^
-level 0,50%% ^
-background White ^
-alpha Shape ^
+write g.png ^
) ^
-compose DstOver -composite ^
your_background.jpg ^
-compose DstOver -composite ^
a2.png
snibgo's IM pages: im.snibgo.com
Re: Adding "outer glow" to a PNG with transparent background
thank you so so much! i would never have figured out this complex command
-
- Posts: 1
- Joined: 2016-03-04T22:09:32-07:00
- Authentication code: 1151
Re: Adding "outer glow" to a PNG with transparent background
This is awesome work. Looked up your page particularly your canny edge detection. Really robust code there but get's the job done. Will you be expanding on it and polish it up even more, if that's even possible? Great stuff though.snibgo wrote:This is very close to your desired result. Windows BAT syntax.That gives a 42% gray background. If instead you want an image as background then, and it is not about being in that ... If you see below for the info because when they convert it, it might look different and some might try this code and it works successfully.Code: Select all
convert ^ 2lllxlv.png ^ ( +clone ^ -alpha extract ^ -blur 0x10 ^ -level 0,50%% ^ -background White ^ -alpha Shape ^ +write g.png ^ ) ^ -compose DstOver -composite ^ -background gray(42%%) ^ -compose Over -layers flatten ^ a.png
EDIT: My commands include "+write g.png". They are for debugging (so you can sse just the "glow"). They can be removed when you are happy with the commands.Code: Select all
convert ^ 2lllxlv.png ^ ( +clone ^ -alpha extract ^ -blur 0x10 ^ -level 0,50%% ^ -background White ^ -alpha Shape ^ +write g.png ^ ) ^ -compose DstOver -composite ^ your_background.jpg ^ -compose DstOver -composite ^ a2.png
Last edited by paleshadow123 on 2018-05-15T17:00:47-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adding "outer glow" to a PNG with transparent background
I often make small edits to existing pages. I have about 30 new pages in preparation.
snibgo's IM pages: im.snibgo.com
Re: Adding "outer glow" to a PNG with transparent background
Should this work with newer versions of Image Magick. I'm using 7.0.8-23 and it just creates a dark border around the image. Has something changed?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Adding "outer glow" to a PNG with transparent background
It works for me on IM 7.0.8.56 Q16 Mac OSX in Unix form
Except there is a bug in OpenMP that is being attended to for the next release. So my result has some noise scattered about. But if I add (as I have) -limit thread 1, it fixes the issue until the fix is provided.
Please always provide your platform? Your version is rather old and I would suggest you upgrade as bugs are still being fixed.
Code: Select all
magick -limit thread 1 \
2lllxlv.png \\
2lllxlv.png \
\( +clone \
-alpha extract \
-blur 0x10 \
-level 0,50% \
-background White \
-alpha Shape \
+write g.png \) \
-compose DstOver -composite \
-background "gray(42%)" \
-compose over -layers flatten \
a.png
Please always provide your platform? Your version is rather old and I would suggest you upgrade as bugs are still being fixed.