I am trying to resize a png file with a single transparent colour.
When I use GD with php I just get a block of colour, the code I am using is as follows -
function MYImage_Resize ($imagefile,$dstfile, $new_w, $new_h){
// get source image info.
$img_data=getimagesize($imagefile);
$src_w=$img_data[0];
$src_h=$img_data[1];
// get source image
$src_img=ImageCreateFromPNG($imagefile);
// create a target image
$dst_img=imagecreate($new_w,$new_h);
// create the thumbnail
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, $src_w, $src_h);
imagepng($dst_img,$dstfile);
// free up the memory.
ImageDestroy($src_img);
ImageDestroy($dst_img);
}
The other method I have tried is and exec with Image Magic. The trouble with that is it keeps producing full colour images when I want them to be paletted. It also turns my transparent colour black.
Any suggestions anyone??
Cris.