imagecreatfrompng() only work for 24bits png ?
| From: | NoWhErEMan | Date: | Wed, 14 Aug 2002 13:05:43 +0000 |
| Subject: | imagecreatfrompng() only work for 24bits png ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-112527@lists.php.net to get a copy of this message | ||
Hi all,
I use following script to generate a resized png image on the fly. I tried
for several hours and found that it
not works for every png image. And finally i found that the
imagecreatfrompng() only works for 24bits png.
i.e my script does not works on my abc.png which is 8bpp(bitsperpixel),
after i increased it;s color depth to 24bits,
it works perfectly. Is it true that the png function only works on 24bpp png
image? (i'm not sure...)
Or put it on this way, how can i increase the color depth in php before
process following script?
I use apache 2.x on win2k, php4.2.2 with php_gd.dll enabled.
<?php
$image = imagecreatefrompng("abc.png");
$newimage = imagecreate(300, 300);
$black = imagecolorallocate($newimage, 0,0,0);
imagecopyresized($newimage, $image, 0, 0, 0, 0, 300, 300, 400, 300);
imagedestroy($image);
imagestring($newimage, 2, 10, 10, "Copyright 2001", $black);
header("Content-type: image/png");
imagepng($newimage);
imagedestroy($newimage);
?>
Thanks in advance.
NoWhErEMaN