#20847 [NEW]: subimages made from transparent images aren' transparent
| From: | gid at gifpaste dot net | Date: | Thu, 05 Dec 2002 23:49:10 +0000 |
| Subject: | #20847 [NEW]: subimages made from transparent images aren' transparent | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-26802@lists.php.net to get a copy of this message | ||
From: gid@gifpaste.net
Operating system: Debian (sid) Linux 2.4.20
PHP version: 4.3.0RC2
PHP Bug Type: GD related
Bug description: subimages made from transparent images aren' transparent
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 bug report at http://bugs.php.net/?id=20847&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20847&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20847&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20847&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20847&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20847&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20847&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20847&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20847&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20847&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20847&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20847&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20847&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20847&r=isapi