Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
10-18-2009, 12:34 AM #1
- Join Date
- Oct 2009
- Thanked 0 Times in 0 Posts
Transparency lost when using imagecopy in PHP
I am desperately trying to create an animated gif from two png files.
I found a great class that does this, and it works fine, except for the transparency, which is lost.
So I decided to narrow down the whole thing to try and locate the origin of the problem, and - lo and behold - the problem has nothing to do with the animation, but with the gd library.
In short, I can't even create an image from png and display it.
Here's a simple version of the code:
<html> <body bgcolor="red"> <?php $im = imagecreatefrompng("thepic.png"); imagealphablending($im, true); imagesavealpha($im, true); $test = imagecreatetruecolor(imagesx($im), imagesy($im)); imagealphablending($test, true); imagesavealpha($test, true); imagecopy($test, $im, 0, 0, 0, 0, imagesx($test), imagesy($test)); header('content-type: image/png'); imagepng($test, "test.png"); ?> <img src=test.png> </body> </html>
Last edited by nathanelmori; 10-18-2009 at 12:37 AM. Reason: Problems with PHP tags
10-18-2009, 12:37 AM #2
- Join Date
- Nov 2007
- Leeds, UK
- Thanked 19 Times in 19 Posts
Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)