Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image transparency.

Status
Not open for further replies.

JamieFuller

Programmer
May 2, 2001
20
GB
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.
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top