2 minuty szukania:
http://pl.php.net/manual/en/function.imagecreatefrompng.phpCytat
I had a problem with PNG files.
My source files were PNG-8 files and i wanted to add some drawings to the Image with alpha blending, but it was not possible only by doing imagecolorallocatealpha() and imagefilledellipse() for example.
I noticed that it was only working for PNG-24 images, but i don't want to use them, because they are to big for my website, but PNG-8 files would be much greater.
My result is that the image has to be converted to PNG-24 after loading and converted back to PNG-8 before saving/output.
This is the script:
<?php
// Load Image and get it's size
$size = getimagesize("png8image.png");
$im = imagecreatefrompng("png8image.png");
// Convert the Image to PNG-24
$im_tc = imagecreatetruecolor($size[0],$size[1]);
imagecopy($im_tc,$im,0,0,0,0,$size[0],$size[1]);
imagedestroy($im);
//Now do what ever you want, all alpha-operation do work
$color = imagecolorallocatealpha ($im_tc,255,255,255,75);
imagefilledellipse ($im_tc,10,10,6,4,$color);
//And now convert it back to PNG-8
$im_result = imagecreate($size[0],$size[1]);
imagecopy($im_result,$im_tc,0,0,0,0,$size[0],$size[1]);
imagedestroy($im_tc);
//And save it
imagepng($im_result,"png8image.png");
?>