-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

4

1 回答 1

0

使用 imagecopyresampled 函数:http ://www.php.net/manual/en/function.imagecopyresampled.php 。具体看第二个例子。

于 2012-10-06T12:40:31.897 回答