Name

transparent( ) — make a color transparent

Synopsis

GD::Image::transparent(colorindex)

The transparent( ) method makes any pixels of color colorindex in an image transparent. Only one color may be transparent at a time; a second call to transparent( ) will override the first call, and will return pixels that were previously transparent to their original color. To turn off transparency in an image, give colorindex a value of -1. To find the index of the transparent color in an image, call transparent( ) without a parameter. To make the color that is closest to white in an image transparent, try:

$mostestwhitest = $image->colorClosest(255,255,255);
$image->transparent($whitest);

This function can be used with setBrush( ) to create irregularly shaped brushes. See the setBrush( ) method for an example of this.

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.