我是小佳 ,未注明原创的,均为转载。
PHP图片缩放函数
上一篇 /
下一篇 2007-03-08 13:37:13
/ 个人分类:PHP杂谈
<?php
function imgageshow($link,$alt="",$x="",$y="",$class='')
{
$size = GetImageSize($link);
$width = $size[0];
$height = $size[1];
if($x!="" or $y!="")
{
if($width>$x){
$temp=$x/$width;
$width=$x;
$height=$height*$temp;
if($height>$y){
$temp=$y/$height;
$height=$y;
$width=$width*$temp;
}
}elseif ($height>$y){
$temp=$y/$height;
$height=$y;
$width=$width*$temp;
if($width>$x){
$temp=$x/$width;
$width=$x;
$height=$height*$temp;
}
}
else{
$width=$width;
$height=$height;
}
}else{
$width=$width;
$height=$height;
}
//echo "<img src="$link" width="$width" height="$height" alt="$alt">";
if($class) echo "<img class='$class' src=\"$link\" width=\"$width\" height=\"$height\" alt=\"$alt\" border=0>";
else echo "<img src=\"$link\" width=\"$width\" height=\"$height\" alt=\"$alt\" border=0>";
}
?>
相关阅读:
- PHP内置输入过滤 (冰刺猬, 2006-11-04)
- 理解Zend 框架 用PHP构建完美的阅读器 (xiaojia, 2006-11-08)
- APMServ5.1.2下ZendStudioServer的安装 (xiaojia, 2006-11-08)
- 图片按钮的问题? (xiaojia, 2006-11-15)
- 使PHP5.1.6支持SOAP (xiaojia, 2006-11-15)
- 一段PHP加密与解密的代码 (xiaojia, 2006-11-25)
- 计算农历的函数-PHP教程,PHP应用 (xiaojia, 2006-12-19)
- php农历日历 (xiaojia, 2006-12-19)
- php curl函数参考 (xiaojia, 2006-12-19)
- php时区设置 (xiaojia, 2007-1-30)
导入论坛
收藏
分享给好友
管理
举报
TAG:
PHP杂谈