首页 > 代码库 > 生成缩略图
生成缩略图
function ResizeImage($im,$maxwidth,$maxheight,$name){
$smalladdrname="../upfile/";//缩略图存放目录位置
$RESIZEWIDTH=‘720‘;//定义最大宽
$RESIZEHEIGHT=‘285‘;//定义最大高
$width = imagesx($im);
$height = imagesy($im);
if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){
$newwidth = 720;
$newheight = 285;
if(function_exists("imagecopyresampled")){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
ImageJpeg ($newim,$smalladdrname.$name);
ImageDestroy ($newim);
}else{
ImageJpeg ($im,$smalladdrname.$name);
}
}
生成缩略图