note 16005 added to function.imagealphablending
| From: | barnabas at kendall dot NOSPAM dot net | Date: | Thu, 11 Oct 2001 21:56:41 +0000 |
| Subject: | note 16005 added to function.imagealphablending | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18844@lists.php.net to get a copy of this message | ||
If you are trying to copy a transparant image on to another image, you might assume that you should
apply the ImageAlphaBlending function to the image that has the transparancy, the source image. In
reality, you must apply the ImageAlphaBlending function to the destination image. Basically
it's saying, "make the specified image respect transparancy".
Here's a real world example. Suppose you want to put your logo on the upper left corner of a
photograph. Your logo is a PNG with transparancy, and the photo is a JPEG. Here's what you
would do:
<?php
$photoImage = ImageCreateFromJPEG('photo.jpg');
ImageAlphaBlending($photoImage, true);
$logoImage = ImageCreateFromPNG('logo.png');
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
ImageCopy($photoImage, $logoImage, 0, 0, 0, 0, $logoW, $logoH);
ImageJPEG($photoImage); // output to browser
ImageDestroy($photoImage);
ImageDestroy($logoImage);
?>
--
http://www.php.net/manual/en/function.imagealphablending.php
http://master.php.net/manage/user-notes.php?action=edit+16005
http://master.php.net/manage/user-notes.php?action=delete+16005
http://master.php.net/manage/user-notes.php?action=reject+16005