请问如何将较大得图片缩小放在固定大小得表格里面? <src img="读出你的图片" width="大小" heigh="大小"> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <a href="图片地址" target="_BLANK"><img src="图片地址" width="宽度" height="高度" alt="提示语言" border="0"></a>不过这个办法不是很好吧,图片会失真吧 实现图片的微缩图<?function makethumb($srcFile,$dstW,$dstH, $type='png') { $data = GetImageSize($srcFile,&$info); switch ($data[2]) { case 1: $im = ImageCreateFromGIF($srcFile); break; case 2: $im = ImageCreateFromJPEG($srcFile); break; case 3: $im = ImageCreateFromPNG($srcFile); break; } $srcW=ImageSX($im); $srcH=ImageSY($im); $dstX=0; $dstY=0; if ($srcW*$dstH>$srcH*$dstW) { $fdstH=round($srcH*$dstW/$srcW); $dstY=floor(($dstH-$fdstH)/2); $fdstW=$dstW; } else { $fdstW=round($srcW*$dstH/$srcH); $dstX=floor(($dstW-$fdstW)/2); $fdstH=$dstH; } $ni=imagecreate($dstW,$dstH); $dstX=($dstX<0)?0:$dstX; $dstY=($dstX<0)?0:$dstY; $dstX=($dstX>($dstW/2))?floor($dstW/2):$dstX; $dstY=($dstY>($dstH/2))?floor($dstH/s):$dstY; $white = ImageColorAllocate($ni, 255,255,255); imagefilledrectangle($ni,0,0,$dstW,$dstH,$white); ImageCopyResized($ni,$im,$dstX,$dstY,0,0,$fdstW,$fdstH,$srcW,$srcH); ImageJpeg($ni); //imagedestroy($im); //imagedestroy($ni); } makethumb("qt_21.jpg",259,193,"jpg");//图片名字,宽,高,生成的扩展名 更改图片的宽度与高度就可以了<img src="1.gif" width="30",height="30">这样显示的是小图片<img src="1.gif" width="300",height="300">这样显示的是大图片怎么不行呢 呵呵,GOOGLE以下就有了上面的如果都试过的话,不应该贴出来,因为都是错的<img src=""onload="javascript:if(this.width>180) this.width=180;if(this.height>210) this.height=210">拿去用吧 一个方法中的参数前面还有个是什么意思? 哪里有PHP教程呀在线等 哪位大大能帮我解密PHP代码。谢谢! 如何获取PHP当前ini文件路径 请教这个session 传递的问题,很菜! 请教这个格式的sql对不对? 配置好PHP环境后,发现我的ASP上传组件不好用了.. php4_calendar.dll文件的找回,在线等 请问哪里可以找到比较详细的PHP参考手册? 输出函数定义 广告窗口? 从mysql的DATE数据中提取时间
不过这个办法不是很好吧,图片会失真吧
<?
function makethumb($srcFile,$dstW,$dstH, $type='png') {
$data = GetImageSize($srcFile,&$info);
switch ($data[2]) {
case 1:
$im = ImageCreateFromGIF($srcFile);
break;
case 2:
$im = ImageCreateFromJPEG($srcFile);
break;
case 3:
$im = ImageCreateFromPNG($srcFile);
break;
}
$srcW=ImageSX($im);
$srcH=ImageSY($im);
$dstX=0;
$dstY=0;
if ($srcW*$dstH>$srcH*$dstW) {
$fdstH=round($srcH*$dstW/$srcW); $dstY=floor(($dstH-$fdstH)/2); $fdstW=$dstW;
} else {
$fdstW=round($srcW*$dstH/$srcH); $dstX=floor(($dstW-$fdstW)/2); $fdstH=$dstH;
}
$ni=imagecreate($dstW,$dstH);
$dstX=($dstX<0)?0:$dstX;
$dstY=($dstX<0)?0:$dstY;
$dstX=($dstX>($dstW/2))?floor($dstW/2):$dstX;
$dstY=($dstY>($dstH/2))?floor($dstH/s):$dstY;
$white = ImageColorAllocate($ni, 255,255,255);
imagefilledrectangle($ni,0,0,$dstW,$dstH,$white);
ImageCopyResized($ni,$im,$dstX,$dstY,0,0,$fdstW,$fdstH,$srcW,$srcH);
ImageJpeg($ni);
//imagedestroy($im);
//imagedestroy($ni);
}
makethumb("qt_21.jpg",259,193,"jpg");//图片名字,宽,高,生成的扩展名
<img src="1.gif" width="30",height="30">这样显示的是小图片
<img src="1.gif" width="300",height="300">这样显示的是大图片
怎么不行呢
上面的如果都试过的话,不应该贴出来,因为都是错的<img src=""onload="javascript:if(this.width>180) this.width=180;if(this.height>210) this.height=210">拿去用吧