= $scale) {
//创建真彩图像资源(imagecreatetruecolor()函数使用GDLibrary创建新的真彩色图像)
$newimg = imagecreatetruecolor($thumbWidth, $thumbHeight);
//图像处理
imagecopyresampled($newimg, $sourceImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, (($height) * $scale), $height);
//以JPEG格式将图像输出到浏览器或文件
ImageJpeg($newimg, $thumbSrc);
}
//宽度优先
if ($ratio < $scale) {
$newimg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($newimg, $sourceImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $width, (($width) / $scale));
ImageJpeg($newimg, $thumbSrc);
}
} else {
if ($ratio >= $scale) {
$newimg = imagecreatetruecolor($thumbWidth, ($thumbWidth) / $ratio);
imagecopyresampled($newimg, $sourceImg, 0, 0, 0, 0, $thumbWidth, ($thumbWidth) / $ratio, $width, $height);
ImageJpeg($newimg, $thumbSrc);
}
if ($ratio < $scale) {
$newimg = imagecreatetruecolor(($thumbHeight) * $ratio, $thumbHeight);
imagecopyresampled($newimg, $sourceImg, 0, 0, 0, 0, ($thumbHeight) * $ratio, $thumbHeight, $width, $height);
ImageJpeg($newimg, $thumbSrc);
}
}
//销毁图像
ImageDestroy($sourceImg);
}
?>