PHP如何实现原比例生成缩略图-创新互联
这篇文章将为大家详细讲解有关PHP如何实现原比例生成缩略图,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

具体如下:
$y){
//图片宽大于高
$sx = abs(($y-$x)/2);
$sy = 0;
$thumbw = $y;
$thumbh = $y;
} else {
//图片高大于等于宽
$sy = abs(($x-$y)/2.5);
$sx = 0;
$thumbw = $x;
$thumbh = $x;
}
if(function_exists("imagecreatetruecolor")) {
$dim = imagecreatetruecolor($yy, $xx); // 创建目标图gd2
} else {
$dim = imagecreate($yy, $xx); // 创建目标图gd1
}
imageCopyreSampled ($dim,$im,0,0,$sx,$sy,$yy,$xx,$thumbw,$thumbh);
header ("Content-type: image/jpeg");
imagejpeg ($dim, false, 100);
?>关于“PHP如何实现原比例生成缩略图”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
分享标题:PHP如何实现原比例生成缩略图-创新互联
文章路径:http://www.jxjierui.cn/article/dppsop.html


咨询
建站咨询
