新弄的图片生成缩略图
PHP代码
<?php
// The file
$filename = 'mm.jpg';
$dstFile="icons/";
$filePath="icons/test.jpg";
// Set a maximum height and width
$width = 100;
$height = 100;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p,$filePath);
?>
$filename图片的名称,包括路径
$dstFile目标路径