From d05f5d8047d2013ebf2d672dd8516c541909e0a3 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Fri, 13 Jul 2012 19:53:44 +1000 Subject: [PATCH] add a recipe to the cookbook it's been a while, and the intuition was interesting --- lib/Imager/Cookbook.pod | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/Imager/Cookbook.pod b/lib/Imager/Cookbook.pod index 9fcf6f29..ad7af17e 100644 --- a/lib/Imager/Cookbook.pod +++ b/lib/Imager/Cookbook.pod @@ -432,6 +432,23 @@ in pixels per centimeter, you would do: Keywords: DPI +=head1 IMAGE MANIPULATION + +=head2 Replacing a color with transparency +X + +To replace a color with transparency you can use the +L method. + + # make a work image the same size as our input + my $work = Imager->new(xsize => $in->getwidth, ysize => $in->getheight, + channels => $in->getchannels); + # and fill it with the colour we want transparent + $work->box(filled => 1, color => $color); + + # get an image with that colour replaced with transparent black + my $out = $work->difference(other => $in); + =head1 AUTHOR Tony Cook -- 2.39.5