ID:               17263
 Comment by:       rbap at yap dot org
 Reported By:      nicolaasuni at tiscali dot it
 Status:           No Feedback
 Bug Type:         GD related
 Operating System: Windows XP Pro or Linux
 PHP Version:      4.2.3
 New Comment:

I experience the same problem on the production system.
For development I use rh8, php4.2.2 and GDlib I guess version 1.8.x

As production rh7, php4.3.1 and the bundled GDlib 2.0 compatible

I am not sure but I think the problem reside in the GD 2.0 lib. 

The following proble occour ONLY with palet image.
Basically my script create a button starting form a basic png and
adding the text.
The script work fine in devel but in production has problem.
When I try to resize the basic button for longer text it seems that
both imagecopyresized and imagecopyresampled does not copy the image.
In the example after the imagecopyresized there is a imagecolorstotal,
it return correcly the number of colors in the image (if you put it
before it return 1, the background).
So it seems that the palet is setted correclty but not the image. If I
create a trucolor image instead of a palet image it works but I do not
have transparency.
Here follow an example code:
<?php
/*
The following script is only an example, the original one is a bit more
complex
it is made only to reproduce the problem.
*/

//the start button.png is a palet image with tranpsarency with around
16 colors
$im = imagecreatefrompng("/path/to/base/button.png");
/* $textwidth = calculation for the new width based on the text; */
$dst_img = imagecreate($textwidth, imagesy($im));
$bkgc  = imagecolorallocate ($dst_img, 0, 0, 255);
/*
imagecopyresized( resource dst_im, resource src_im, int dstX, int dstY,
int srcX, int srcY, int dstW, int dstH, int srcW, int srcH )
*/
imagecopyresized($dst_img, $im, 0, 0, 0, 0, $textwidth, imagesy($im),
1, imagesy($im));
//echo "<p>Total Color: " . imagecolorstotal ($dst_img) ."</p>";
imagecolortransparent($dst_img, $bkgc);
header("Content-type: image/png");
Imagepng($dst_img);
?>


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

[2003-01-15 03:39:58] jukkaho at mail dot student dot oulu dot fi

I was hit by this bug also.

GD 2.0 bundled with PHP 4.3.0 has this bug also. This was tested with
Linux.

No output is coming when I'm trying to use imagecreatefrompng() from an
indexed color image to a imagecreate()-image using imagecopyresized().

When using imagecreatetruecolor()-image as a target, copying works ok.

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

[2002-11-22 13:22:43] th at hahn-software dot de

PHP Version 4.2.3 with GD Library 1.8.4(!!) => imagecopyresized works
'without' Color Problems.

PHP Version 4.2.3 with GD Library above 2.0
=> imagecopyresized change the Colors dramatical

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

[2002-10-14 19:26:50] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2002-09-27 06:31:40] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip



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

[2002-09-27 04:51:29] nicolaasuni at tiscali dot it

Hi, the problem persist using the latest 4.2.3.

The problem is on the destination image format.
If you use a true color image there's no problem but if you use a
paletted image the problem persist.

The only way to avoid this problem is to have a destination image in
true color but unfortunately there are some cases where I need to
resize a paletted image.
I've also try to use a truecolor image and convert it to paletted after
conversion but the result is very poor (and slow).

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/17263

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

Reply via email to