imagecopyresampled()
| From: | Klaus Reimer | Date: | Tue, 29 Jun 2004 14:52:49 +0000 |
| Subject: | imagecopyresampled() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-189225@lists.php.net to get a copy of this message | ||
Hello,
I have a problem with imagecopyresampled() and I'm not sure if this is a bug
in GD or PHP or it's a feature. I'm trying to do the following (This example
doesn't make much sense, it's just a simple way to reproduce the problem):
I have an alphatransparent image 512x512. I want to resample that image to
256x256 and draw it onto a blue background. After that I want the background
color to be pixel-transparent.
With GD I'm doing it like that:
1. Create new true color image with a size of 255x255
2. Allocate a background color and fill the new image
3. Load the alphatransparent PNG
4. Render the PNG on the background image with imagecopyresampled
5. Define the background color as transparent (imagecolortransparent)
6. Save the image as PNG.
Now here is the result:
http://www.ailis.de/~k/test/imagecopyresampled/255.png
If I do exactly the same with a target image size which is a base of 2 (2, 4,
8, 16, .... 256) it works. See here:
http://www.ailis.de/~k/test/imagecopyresampled/256.png
With imagecopyresized everything works fine. But imagecopyresampled has
problems with "binary uneven" target sizes. Is this a GD bug? I'm using PHP
4.3.3 with GD 2.0.23 (The stuff from current Debian Sarge). Does anybody know
a solution or a workaround?
--
Bye, K <http://www.ailis.de/~k/> (FidoNet:
2:240/2188.18)
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger k@ailis.de to get public key)