Page 1 of 1
GIMP Style Tranparency
Posted: 2014-02-28T10:51:45-07:00
by armstrong091
In Gimp when you use the Color-to-alpha tool - to remove a background color, for example - any selected area will also become semi transparent.
I would like to automate this process using Image magick, but have not been able to find how to do it. So far, any color-to-alpha exapmles that i have found strictly remove the color specified, not producing a gradient of transperency.
Below is an example - made in Gimp - of what i'm looking to be able to do with ImageMagick. I Color-to-alpha'd the white in the image then pasted it onto its original self to illustrate the semi transperent effect.
Any and all help is appreciated!

Re: GIMP Style Tranparency
Posted: 2014-02-28T11:02:55-07:00
by snibgo
I haven't compared this to what Gimp does, but ...
Code: Select all
convert in.png -alpha off ( +clone -negate ) -compose CopyOpacity -composite out.png
... makes a copy of the image, negates that, and copies the tones into the alpha channel. What was white becomes transparent; black becomes opaque.
Re: GIMP Style Tranparency
Posted: 2014-02-28T11:09:01-07:00
by armstrong091
I'm getting an unexpected token error on the '(' . I should have mentioned before that i'm using ImageMagick 6.7.7-10 in Linux
Re: GIMP Style Tranparency
Posted: 2014-02-28T11:23:56-07:00
by snibgo
In Unix commands you need to escape parentheses: \( and \).
Re: GIMP Style Tranparency
Posted: 2014-02-28T11:29:29-07:00
by armstrong091
I had tried that but It gave me a more complicated error...
Code: Select all
$ convert smiley.png -alpha off \( +clone -negate \) compose CopyOpacity -composite out.png
convert.im6: unable to open image `compose': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `compose' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `CopyOpacity': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `CopyOpacity' @ error/constitute.c/ReadImage/544.
I apologize for being a newbie on this, so far the extend of my experience with IM has been cropping/resizing/converting.
I appreciate your help.
Re: GIMP Style Tranparency
Posted: 2014-02-28T11:30:54-07:00
by fmw42
convert smiley.png -alpha off \( +clone -negate \) compose CopyOpacity -composite out.png
You need -compose CopyOpacity (you left of the minus sign)
Re: GIMP Style Tranparency
Posted: 2014-02-28T11:41:57-07:00
by armstrong091
A HA! It worked. This is exactly what i was looking for . Is there any way to vary the intensity of the transparency? The Result is very transparent...
I guess i could superimpose the image on itself a couple times.. though that seems sloppy.
Thanks again for your help.
Re: GIMP Style Tranparency
Posted: 2014-02-28T11:51:42-07:00
by fmw42
try
Code: Select all
convert smiley.png -alpha off \( +clone -negate -evaluate multiply 2 \) -compose CopyOpacity -composite out.png
or
convert smiley.png -alpha off \( +clone -negate -evaluate add 50% \) -compose CopyOpacity -composite out.png
Adjust the factors 2 or 50% as desired