How to convert PNG to 8-bit PNG using PHP GD library
I want to write a routine which takes PNG image path as parameter and convert that image into 8-bit PNG image. I need to use PHP GD library for this. To convert any PNG image to 8-bit PNG use this function, I've just created function convertPNGto8bitPNG () function convertPNGto8bitPNG ($sourcePath, $destPath) { $srcimage = imagecreatefrompng($sourcePath); list($width, $height) = getimagesize($sourcePath); $img = imagecreatetruecolor($width, $height); $bga = imagecolorallocatealpha($img, 0, 0, 0, 127); imagecolortransparent($img, $bga); imagefill($img, 0, 0, $bga); imagecopy($img, $srcimage, 0,