[magick-users] How to change the color of an transparent png
Anthony Thyssen
anthony at griffith.edu.au
Wed May 14 23:21:53 PDT 2008
froesi on wrote...
| Hi guys,
|
| I've a vector graphic with a single color as an png file.
|
That is not posible,
It is posible to have a vector graphic RENDERED as a PNG image 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. I
| need something like this
|
| http://www.lsus.edu/sc/math/rmabry/imagemagick/multireplace
| ->>"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. Thank you,
|
If the document only has a gradient of two colors and no other colors
involved. Then the solution is simple, if not then you need something
like multi-replace.
First convert the image to greyscale, and normalize it to maximised the color
gradient. Do not use -normalize as it has some clipping add for handling
JPEG images....
-colorspace gray -contrast-stretch 0
See
http://imagemagick.org/Usage/color/#grayscale
http://imagemagick.org/Usage/color/#contrast-stretch
You could also extract a color channel, and normalize (stretch) that
image...
http://imagemagick.org/Usage/channels/#separate
now use either color gradient replacement or a mathematically
re-coloring method. Lots of these are shown in IM examples, Color
Modifications
http://imagemagick.org/Usage/color/
Alturnativally have two images of the colors (or pattern) wanted for
each end of the gradient, and use the normalized image as a mask
using a three image composite...
http://imagemagick.org/Usage/compose/#mask
Anthony Thyssen ( System Programmer ) <A.Thyssen at griffith.edu.au>
-----------------------------------------------------------------------------
"Oh, the pain... the pain of it all!" -- Doctor Smith, Lost in Space
-----------------------------------------------------------------------------
Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/
More information about the Magick-users
mailing list