ID: 23815
Updated by: derick@php.net
Reported By: bjorn at smokingmedia dot com
-Status: Open
+Status: Feedback
Bug Type: GD related
Operating System: Linux pluto 2.4.18lvm-r1
PHP Version: 4.3.1
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2003-05-26 11:43:05] bjorn at smokingmedia dot com
[[There are similar bugs in the system, but they are either closed or
said to be fixed... i think it's still not fixed..]]
i wanted to do the following. Use a transparent PNG-24(24 bits) file,
with an alpha-channel (with a drop-shadow) and merge it to a background
color. (see sample code).
this works:
imagecopy($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y);
this doesn't work:
imagecopymerge($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y,
99);
-> with any number instead of 99
sample link:
[change the hex color code to change backgroundcolor]
this is Okay
http://www.smokingmedia.com/test_gd_fb/test?bg=ffee22
this is not okay:
http://www.smokingmedia.com/test_gd_fb/test_nk?bg=ffee22
sample code:
<?php
if(!isset($_GET[bg]) || $_GET[bg] == ""){
$bg = "eeeeee";
}
else{
$bg = $_GET[bg];
}
$im = "test01.png";
//
// function to convert hex colorcode to decimal
//
function colordecode($hex){
$code[r] = hexdec(substr($hex, 0 ,2));
$code[g] = hexdec(substr($hex, 2 ,2));
$code[b] = hexdec(substr($hex, 4 ,2));
return $code;
} // end func colordecode
// create the resource id
$image_id = imageCreateFromPNG($im);
// get image size
$im_X = ImageSX($image_id);
$im_Y = ImageSY($image_id);
// create a truecolor background image of the right size
$backgroundimage = imagecreatetruecolor($im_X, $im_Y);
// get the desired backgroundcolor:
$code = colordecode($bg);
$backgroundcolor = ImageColorAllocate($backgroundimage, $code[r],
$code[g], $code[b]);
ImageFilledRectangle($backgroundimage, 0, 0, $im_X, $im_Y,
$backgroundcolor);
// merge the two together with alphablending on!
ImageAlphaBlending($backgroundimage, true);
// this works:
imagecopy($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y);
// this is where things go wrong:
//imagecopymerge($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y,
99);
// output the image:
Header( "Content-type: image/png");
ImagePNG($backgroundimage);
// destroy the memory
ImageDestroy($backgroundimage);
ImageDestroy($image_id);
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23815&edit=1