Page 1 of 1

setting transparency - fading an image

Posted: 2010-07-27T06:31:26-07:00
by jjj0923
I've read about the opague feature and wondered is there's a simple way to fade an entire image by some percentage instead of attempting to fade each color separately?

thanks in advance...

Jeff

Re: setting transparency - fading an image

Posted: 2010-07-27T10:00:45-07:00
by fmw42
Do you mean a global fade so all pixels have the same transparency or do you mean a gradient fade so that it is more transparent on one side than the other?

If the former, then this will set the opacity to 25% (75% transparent)

convert <image> -alpha on -channel a -evaluate set 25% result.png

Re: setting transparency - fading an image

Posted: 2010-07-27T11:25:25-07:00
by jjj0923
yes, global fade - so thank you very much!

Jeff

Re: setting transparency - fading an image

Posted: 2010-07-27T18:12:17-07:00
by anthony
Also do you mean fade to a color (like white or black) Also known as de-contrasting.
Or do you mean to transparency?

To a color you can use -colorize. for example

Code: Select all

convert input  -fill black -colorize 50%  output
That will fade the image to black by overlaying a 50% transparent black.
It also will not 'fade' any fully-transparent areas in the image toward black.

See IM examples, Colorize

A more controls greyscale fading can be achieved using Reversed Level Adjustments

Re: setting transparency - fading an image

Posted: 2010-07-28T05:12:01-07:00
by jjj0923
I mean transparency

- jeff

Re: setting transparency - fading an image

Posted: 2010-07-29T10:28:43-07:00
by jjj0923
[root@localhost seo-images]# convert dim.jpg -alpha on -channel a -evaluate set 50% results.jpg
convert: unrecognized option `-alpha'.


??? - what now?

Re: setting transparency - fading an image

Posted: 2010-07-29T10:31:44-07:00
by jjj0923
I found that this worked fine though:

convert dim.jpg -fill white -colorize 50% results.jpg

Re: setting transparency - fading an image

Posted: 2010-07-29T19:15:42-07:00
by anthony
jjj0923 wrote:I found that this worked fine though:

convert dim.jpg -fill white -colorize 50% results.jpg
That is not transparency fading, but fading to 'white'.

For a image destined for viewing on a white background such as in a browser, that will work fine, and even work better for older Internet Explorers that did not handle PNG transparency right. Or for JPEG images which does not handle transparency at all!.

-alpha replaces +/-matte functionality, providing many.

-matte is equivelent to -alpha set which is what you should be using.

So try this...

Code: Select all

convert dim.jpg -matte -channel a -evaluate set 50% results.jpg
You should NOT use -alpha on unless you know what you are doing. It is too basically too simple!

ASIDE: For new images -alpha set and -alpha on are equivelent. But for old images possibility containing old alpha channels -alpha on can cause problems you should use -alpha set, which will ensure alpha is present, but does not change the current look of the image if an old alpha channel was present.

For more details see IM Examples, Basics, Controlling Image Transparency
http://www.imagemagick.org/Usage/basics/#alpha

Re: setting transparency - fading an image

Posted: 2010-07-29T19:42:47-07:00
by fmw42
jjj0923 wrote:[root@localhost seo-images]# convert dim.jpg -alpha on -channel a -evaluate set 50% results.jpg
convert: unrecognized option `-alpha'.


??? - what now?

Your IM version is too old. What version are you using? In old versions use -matte, in newer versions the more correct equivalent is -alpha set