ID: 23815
Comment by: checat at yandex dot ru
Reported By: bjorn at smokingmedia dot com
Status: No Feedback
Bug Type: GD related
Operating System: Linux pluto 2.4.18lvm-r1
PHP Version: 4.3.1
New Comment:
PHP version: 5.2.9
CentOS 4
Reproduce code:
<?php
$bg =
imagecreatefrompng('http://guppi.spb.ru/php-bug-23815/bg.png');
$over =
imagecreatefrompng('http://guppi.spb.ru/php-bug-23815/over.png');
imagecopymerge($bg, $over, 0,0,0,0,32,32,100);
imagecopymerge($bg, $over, 16,0,0,0,32,32,50);
imagepng($bg, 'imagecopymerge.png');
?>
Expected result:
Proper image:
http://guppi.spb.ru/php-bug-23815/proper.png
Actual result:
Wrong image:
http://guppi.spb.ru/php-bug-23815/imagecopymerge.png
Previous Comments:
------------------------------------------------------------------------
[2003-06-02 17:27:30] [email protected]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
------------------------------------------------------------------------
[2003-05-26 11:50:26] [email protected]
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
------------------------------------------------------------------------
[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