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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize PNG with transparent background

Status
Not open for further replies.
Aug 23, 2004
174
US
I'm trying to resize a png with a transparent background. The file gets saved but when I try to view it, it says no preview available. This is the code i'm using.

Code:
$newImg = imagecreatetruecolor($newwidth, $newheight);
imagealphablending($newImg, false);
imagesavealpha($newImg,true);
$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
imagefilledrectangle($newImg, 0, 0, $newwidth, $newheight, $transparent);
imagecopyresampled($newImg, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$filename= $output_dir.$cur_file;
@imagepng($newImg, $filename, 95);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top