ID:               20847
 Comment by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
 Bug Type:         GD related
 Operating System: Debian (sid) Linux 2.4.20
 PHP Version:      4.3.0RC2
 New Comment:

Additional note:  If I try to directly copy the transparent png image
over the photo image, it works like a charm, it's only when I need to
create an intermediate subimage that it doesn't work.


Previous Comments:
------------------------------------------------------------------------

[2002-12-05 17:49:10] [EMAIL PROTECTED]

I'm running 4.3.0RC2 with the built in gd library.

What I'm trying to do is create a transparent subimage from a series of
pngs that have an 8 bit alpha channel.  I then can resize the subimage,
rotate it, whatever over another photograph.

I realize there's the imagecolortransparent() function so you can
specify one color on your image as transparent, but this does not help
the case when you want full 8-bit transparency.

Expected results:  The subimage should have an 8-bit alpha channel like
the png's that's it's created from and should be transparent when
imagecopy()'d over the photoimage.

Actual results:  I get a black box where I tried to copy the image.

Web page source:  http://pimpbot.qooqle.com/gid/php_bug1/
(example png and jpg images I used are loacated here)

Example source:
<?
// load photo image
$photo_img = imagecreatefromjpeg('images/kittybath.jpg');
imagealphablending($photo_img, TRUE);

// load just one letter for now to test
// this is a transparent png with an 8 bit alpha channel
$letter_img = imagecreatefrompng('images/S.png');
imagealphablending($letter_img, TRUE);
$x = imagesx($letter_img);
$y = imagesy($letter_img);

// create the words image, same size as the letter for now
// this is also referred to as the subimage, it should also have an 8
bit alpha channel
// like the letter_img
$words_img = imagecreate($x, $y);
imagepalettecopy($words_img, $letter_img);
imagealphablending($words_img, TRUE);

// copy letter image onto words image
imagecopy($words_img, $letter_img, 0, 0, 0, 0, $x, $y);

// now that we have the words image, we can resize it, rotate it, etc
// but we won't do that for now to keep things simple

// copy words image onto photo image
imagecopy($photo_img, $words_img, 50, 50, 0, 0, $x, $y);

// write out new image
imagejpeg($photo_img, 'images/new.jpg', 90);
?>

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=20847&edit=1

Reply via email to