note 46030 added to function.imagecolortransparent
| From: | php_commentet5mmde at osu1 dot php dot net | Date: | Mon, 27 Sep 2004 17:02:16 +0000 |
| Subject: | note 46030 added to function.imagecolortransparent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77438@lists.php.net to get a copy of this message | ||
In fact this function can be used for two purposes:
A.) to work with transparency while dealing with images in php (see watermark example)
B.) to create a partially transparent picture
For A.) one can work with truecolor images with some regulations, but B.) can only be used with
palette-based images (= indexed = created with imagecreate not imagecreatetruecolor) and formats
that support transparency (png, gif).
For instance if you want to cut out a color out of a give picture that is in truecolor, use the
following method to first convert it to palette-based image, assign the transparency and give it to
the browser as png:
<?
$img = imagecreatefromjpeg('test.jpg');
imagetruecolortopalette($img, false, 256); // convert
$white = imagecolorresolve($img, 255, 255, 255); // resolve given palette entry
imagecolortransparent($img, $white);
header("Content-type: image/png");
imagepng($img);
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagecolortransparent.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46030
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46030&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46030&report=yes
Search -- http://master.php.net/manage/user-notes.php