【php开源代码栏目提醒】:网学会员为需要php开源代码的朋友们搜集整理了resize.php相关资料,希望对各位网友有所帮助!
本例中将把一幅图像重采样为原始大小的一半。
<?php
// The file
$filename = 'exam01.png';
$percent = 0.5;
// Content type
header('Content-type: image/png');
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefrompng($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagepng($image);
?>