-3

Possible Duplicate:
How do I resize pngs with transparency in PHP?

I have a script which creates a PNG by combining multiple files:

$img_width = 950;
$img_height = 950;
$final_img = imagecreatetruecolor($img_width, $img_height);
imagesavealpha($final_img, true);
$trans_colour = imagecolorallocatealpha($final_img, 0, 0, 0, 127);
imagefill($final_img, 0, 0, $trans_colour);

foreach ($images_array as $image) {
    $image_layer = imagecreatefrompng($image);
    imagecopy($final_img, $image_layer, 0, 0, 0, 0, $img_width, $img_height);
}

imagesavealpha($final_img, true);
imagealphablending($final_img, true);

header('Content-Type: image/png');
imagepng($final_img);

All the images I'm combining at 950px square. How can I make it so the returned image is say 200 x 200 ?

Thanks

Community
  • 1
  • 1
Sebastien
  • 2,607
  • 9
  • 30
  • 40

1 Answers1

0

Use the imagecopyresampled function: http://www.php.net/manual/en/function.imagecopyresampled.php. Specifically see the second example.

Joshua Dwire
  • 5,415
  • 5
  • 29
  • 50