Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Creating transparent images using Imager

by tonyc (Friar)
on Apr 28, 2009 at 00:20 UTC ( [id://760478]=note: print w/replies, xml ) Need Help??


in reply to Creating transparent images using Imager

Imager's default combining mode is "none" - which replaces the target pixel, you can supply a fill object (or get Imager to make one) that uses the "normal" mode to get the transparency effect you're after:

use strict; use warnings; use Imager; my $img = Imager->new(xsize=>700, ysize => 500, channels => 4); # setting Imager::Color->new($red, $green, $blue, $alpha); my $blue = Imager::Color->new( 0, 0, 255, 255); my $red = Imager::Color->new( 255, 0, 0, 63); $img->box(color => $blue, xmin=>10, ymin=>30, xmax=>200, ymax=>300, filled=> 1); $img->box(fill => { solid => $red, combine => 'normal' }, xmin=>50, ymin=>80, xmax=>250, ymax=>350); $img->write(file => 'transbox.png') or die;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://760478]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2025-06-17 16:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.