Page 1 of 1
How to change the color of an transparent png
Posted: 2008-05-14T10:41:04-07:00
by froesi
Hi guys,
I've a vector graphic with a single color as an png file. To look smooth the
graphic has an anti aliasement.
I tried something like this
-fuzz 4 % -fill "#FFFFFF" -opaque "#000000", but the thing is, that not
every pixel of the graphic will be conerted to the new color. There is still a halo of the original color around the shape.
I need something like this
http://www.lsus.edu/sc/math/rmabry/imag ... ltireplace
->>"Replace black with blue #0000ff:"
I've no idea how to get this. It would be really great, if someone can give
me a hint or a quick example
Thank you,
cheers
froesi
Re: How to change the color of an transparent png
Posted: 2008-05-14T12:56:46-07:00
by fmw42
I don't know if this is the most efficient way, but you could try
separating the image and the alpha channel, modify the image, then
recombine the alpha channel with the modified image.
convert image \
\( -clone 0 +matte -fuzz 4 % -fill "#FFFFFF" -opaque "#000000" \) \
\( -clone 0 -channel matte -separate +matte \) \
-delete 0 +matte -compose copy_opacity -composite result
see
http://www.imagemagick.org/Usage/compose/#copyopacity
Re: How to change the color of an transparent png
Posted: 2008-05-15T11:01:19-07:00
by froesi
Thank you for your reply, but the thing isn't workung.
It changes the background to #FFFFFF instead of the picture.
i do the following.
convert -draw 'affine 1,0,0,1,6,77 image Over 0,0 0,0 "background.jpg"' \( -clone 0 +matte -fuzz 5% -fill "#ffffff" -opaque "#000000" \) \( -clone 0 -channel matte -separate +matte \) -delete 0 +matte -compose copy_opacity -composite -draw 'affine 1.4375694885254,0,0,1.4375694885254,242.08215,70.325475 image Over 0,0 0,0 "gra.png"' wallpaper.jpg 2>&1
Do you have another idea what i can do or what is wrong?
thank you guys
cheers
froesi
Re: How to change the color of an transparent png
Posted: 2008-06-03T19:45:58-07:00
by anthony
the problem is you image is NOT a single color, but a gradient of colors, even if one color is 'transparent'.
If the image has a transparent background, then you can just -colorize the image to set a different color.
If your image is two colors (a gradient between those two colors)
then you can first gray scale and normalize the image to pure black and white. You can then recolor the result using techniques found in..
http://imagemagick.org/Usage/channels/#masks
or do a histogram recoloring using
http://imagemagick.org/Usage/color/#linear
OR a gradient replacement by lookup
http://imagemagick.org/Usage/color/#recolor
You have lots of options that do NOT involve horrible single color replacement, which is the cause of you halo effect!