Re: Replacing one colour with a different (transparent) colour (PNG)
From: Aaron Dalton (email@example.com)
Date: Thu 05 Feb 2004 - 03:02:34 GMT
Next message: Tony Cook: "Re: Replacing one colour with a different (transparent) colour (PNG)"
On February 3, 2004 08:33 pm, Tony Cook wrote:
> You might want to look at using transform2() to do the conversion:
> my $out = Imager::transform2(
> rpnexpr => 'x y getp1 !p @p red 255 eq @p green 255 eq and @p
> blue 255 eq' .' and 0 0 0 0 rgba @p red @p green @p blue 255 rgba if'
> }, $input_image);
Thank you so much for your help thusfar, Tony. I'm trying to get my
head around the syntax of this command. What I want to do is write a
generic "colour replacement" subroutine that takes the rgb of the
colour to replace, along with the rgba of the colour to transform it
into. So far I've done:
rpnexpr => 'x y getp1 !p @p red '.$redOld.' eq @p green '.$greenOld.' eq
and @p blue '.$blueOld.' eq and 0 0 0 0 rgba @p red @p green @p blue
255 rgba if'
I'm not quite sure what is happening with the 4 0's in a row. Where
should I be putting the variables to interpolate? Sorry for so many
questions. Any tutorials anywhere on the transform syntax? =) I'll
pour over the documentation again tomorrow and see what I can glean.
Thanks again for all your time.