PHP 缩放图片(2)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-20 18:32 点击:次
exit();
}
$im = imagecreatefromgif($srcFile);
break;
case 2:
if(!function_exists("imagecreatefromjpeg"))
{
echo "the GD can't support .jpeg, please use other picture! <a href='javascript:history.back();'>back</a>";
exit();
}
$im = imagecreatefromjpeg($srcFile);
break;
case 3:
$im = imagecreatefrompng($srcFile);
break;
}
//计算缩略图的宽高
$srcW = imagesx($im);
$srcH = imagesy($im);
$toWH = $toW / $toH;
$srcWH = $srcW / $srcH;
if ($toWH <= $srcWH)
{
$ftoW = $toW;
$ftoH = (int)($ftoW * ($srcH / $srcW));
}
else
{
$ftoH = $toH;
$ftoW = (int)($ftoH * ($srcW / $srcH));
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>