JamieFuller
Programmer
I have written a script that uploads a picture, (jpg).
I need to resize a copy to a thumbnail size and then make it transparent (where there is white) and save as a png.
I have every thing working but the transparency.
heres my code.
Please help!!!
Jamie Fuller
Kindest Regards
Jamie
I need to resize a copy to a thumbnail size and then make it transparent (where there is white) and save as a png.
I have every thing working but the transparency.
heres my code.
Code:
// Load image from jpg
$src_img = ImageCreateFromJPEG($imgdir.$img);
// Get image size
$org_h = imagesy($src_img);
$org_w = imagesx($src_img);
// Initialize destination image
$dst_img = imagecreatetruecolor(80,60);
// Resize it
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, 80, 60, $org_w, $org_h);
// Convert to 256 colours, set transparency and then save it!
imagetruecolortopalette ($dst_img, false, 255);
$white = imagecolorallocate ($dst_img, 255, 255, 255);
imageColorTransparent($dst_img, $white);
ImagePNG($dst_img, $imgdir."tn_".$img);
// clean up
imageDestroy($src_img);
imageDestroy($dst_img);
Please help!!!
Jamie Fuller
Kindest Regards
Jamie