Need Help on Feather effect

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Need Help on Feather effect

Post by mjamal »

Hello Team,

I need to apply feather effect on any of the transparent image which are having different corners and I want to apply the 20px feather for the input image, same as we are applying on photoshop.

Please let me know your valuable inputs which are available in image magick or imagick library.
I have added one below input file for sample which I am using for testing purpose.
5ba0fadb35c3b.png
5ba0fadb35c3b.png (68.48 KiB) Viewed 44623 times
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need Help on Feather effect

Post by fmw42 »

Try this Imagemagick command line. Adjust the blur level as desired. Sorry I do not know Imagick equivalents.

Code: Select all

convert 5ba0fadb35c3b.png -channel a -blur 0x7 -level 50x100% +channel result.png

______________________

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Need Help on Feather effect

Post by mjamal »

Thank you Fred, your provided code is working as expected, only I need to know where exactly I need to put the value 25 for the 25px feather radius in your below provided script, It is at "-level 25x100%" or "-blur 0x25" for setting the 25px feather effect same as in photoshop?

convert 5ba0fadb35c3b.png -channel a -blur 0x7 -level 50x100% +channel result.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need Help on Feather effect

Post by fmw42 »

It would be in the blur. But Imagemagick does not use the same blur arguments as photoshop. So you will need adjustment the blur value where I have 7 to something that matches what you get from photoshop. My guess was 7 but 8 might be better. Since 8x3=24 is close to 25.

Alternately, try this variation.

Code: Select all

convert 5ba0fadb35c3b.png -channel a -blur 25x65000 -level 50x100% +channel result.png
Here I specified a 25 pixel linear blur rather than the 7 or 8 pixel gaussian blur sigma. So if 25 does not work adjust the 25 value from 25x65000 argument. Do not change 65000.
mjamal
Posts: 62
Joined: 2017-12-27T06:13:59-07:00
Authentication code: 1152

Re: Need Help on Feather effect

Post by mjamal »

Hello Team,

Can anyone please help me for applying the feathering differently from the horizontal and vertically for an image.
I am using below command but unfortunately it is taking long time to apply the feathering on result image.

Code: Select all

exec("convert checkFeather-TRIM.png \( +clone -alpha extract -threshold 0% +duplicate -compose blur -define compose:args='11x21' -composite -level 50x100% \) -alpha off -compose CopyOpacity -composite result112.png");
Below is the input image URL.
https://www.dropbox.com/s/pldzxwx1ss37o ... M.png?dl=0

Please provide any solution so that I can apply feathering as quick as possible, right now for this mentioned image the script taking around 40 seconds.

Thanks in advanced.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Need Help on Feather effect

Post by snibgo »

You are using "-compose blur", which gives a variable size blur, where the size is according to the mask (which in your case is a duplicate of the extracted alpha). As almost all pixels have alpha either 0 or 100%, the variable effect is wasted. Do you really want a variable blur? If not, a simple "-blur 0x10" or whatever is far quicker.

Even quicker, you don't need to extract alpha and finally copy-opacity. Simply apply the blur to just the alpha channel:

Code: Select all

convert checkFeather-TRIM.png -channel A -blur 0x10 +channel out.png
snibgo's IM pages: im.snibgo.com
Post Reply