php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17263 imagecopyresampled - imagecopyresized
Submitted: 2002-05-15 18:21 UTC Modified: 2002-10-14 19:26 UTC
Votes:15
Avg. Score:4.7 ± 0.5
Reproduced:12 of 13 (92.3%)
Same Version:6 (50.0%)
Same OS:11 (91.7%)
From: nicolaasuni at tiscali dot it Assigned:
Status: No Feedback Package: GD related
PHP Version: 4.2.3 OS: Windows XP Pro or Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2002-05-15 18:21 UTC] nicolaasuni at tiscali dot it
Using php_gd2.dll and paletted image the method imagecopyresized return a monochromatic rectangle and the method imagecopyresampled return a blank rectangle.
These methods works fine only with true color images.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-28 03:02 UTC] sniper@php.net
Please add a short example script here which can be used
to reproduce this.

 [2002-06-28 06:02 UTC] nicolaasuni at tiscali dot it
This is an examle script that produce the error explained in my previous message. For this test I've used a 1x50 pixel PNG image with 50 different paletted colours.

<?php

$src_img_file_name = "source_image.png"; // filename of source file

$dest_img_width = 150; // destination image width
$dest_img_height = 50; // destination image height

$src_img_width = 1; // source image width
$src_img_height = 50; // source image height

// create a blank image
$dest_img = @ImageCreate($dest_img_width, $dest_img_height) or die ("Cannot Initialize new GD image stream");

// create image from source image file
$src_img = imagecreatefrompng($src_img_file_name);

// copy source image to destination image resampled
imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $dest_img_width, $dest_img_height, $src_img_width, $src_img_height);

// copy source image to destination image resized
//imagecopyresized($dest_img, $src_img, 0, 0, 0, 0, $dest_img_width, $dest_img_height, $src_img_width, $src_img_height);

//send image to output
header("Content-type: image/png");
ImagePng($dest_img);

?>
 [2002-07-02 21:56 UTC] sniper@php.net
Please try this snapshot:

http://snaps.php.net/win32/php4-win32-latest.zip

 [2002-09-11 11:08 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 [2002-09-12 03:52 UTC] nicolaasuni at tiscali dot it
The problem persist using the current PHP version 4.2.2
 [2002-09-12 03:53 UTC] nicolaasuni at tiscali dot it
The problem persist using the current PHP version 4.2.2
 [2002-09-12 06:04 UTC] sniper@php.net
btw. PHP 4.2.2 is not the latest release..
If that doesn't work, try this:

http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-09-26 20:07 UTC] sniper@php.net
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.


 [2002-09-27 04:51 UTC] 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).
 [2002-09-27 06:31 UTC] sniper@php.net
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-10-14 19:26 UTC] 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-11-22 13:22 UTC] 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
 [2003-01-15 03:39 UTC] 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.
 [2003-04-04 05:50 UTC] rbap at yap dot org
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);
?>
 [2003-04-04 05:53 UTC] rbap at yap dot org
Another comment to the above.
On the production server I had the same problem with php4.2.2 and external (of course) GDlib 2.0.
That's why I think the problem is in the GDlib version.
 [2003-04-04 06:39 UTC] rbap at yap dot org
If you experience such problem, 
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

It worked for me.
This problem is still in the php4.3.1, to solve it use the snapshot
 [2003-12-04 15:29 UTC] ahensen at chello dot nl
I experience the same problem with PHP 4.3.4 / GD bundled (2.0.15 compatible) on a Windows XP box.
 [2003-12-04 17:48 UTC] ahensen at chello dot nl
Sorry , please ignore my previous posting. I rushed into my conclusion a little bit to fast
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 04:01:27 2024 UTC