01 if($srcW<=$toW && $srcH<=$toH ) return TRUE;02 $toWH=$toW/$toH;03 $srcWH=$srcW/$srcH;04 if($toWH<=$srcWH)05 {06 $ftoW=$toW;07 $ftoH=$ftoW*($srcH/$srcW);08 }09 else10 {11 $ftoH=$toH;12 $ftoW=$ftoH*($srcW/$srcH);13 }然后用下面的大片代码替换:
01 $ftoW=$toH;02 [size=; font-size: inherit,inherit] $ftoH=$toH;03 ///04 [size=; font-size: inherit,inherit] if( $srcH<=$toH && $srcW<=$toW )05 [size=; font-size: inherit,inherit] {06 [size=; font-size: inherit,inherit] $ftoW=$srcW;07 [size=; font-size: inherit,inherit] $ftoH=$srcH;08 [size=; font-size: inherit,inherit] if(function_exists("imagecreatetruecolor"))09 [size=; font-size: inherit,inherit] {10 [size=; font-size: inherit,inherit] @$ni = imagecreatetruecolor($ftoW,$ftoH);11 [size=; font-size: inherit,inherit] if($ni)12 [size=; font-size: inherit,inherit] {13 [size=; font-size: inherit,inherit] imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);14 [size=; font-size: inherit,inherit] }15 [size=; font-size: inherit,inherit] else16 [size=; font-size: inherit,inherit] {17 [size=; font-size: inherit,inherit] $ni=imagecreate($ftoW,$ftoH);18 [size=; font-size: inherit,inherit] imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);19 [size=; font-size: inherit,inherit] }20 [size=; font-size: inherit,inherit] }21 [size=; font-size: inherit,inherit] else22 [size=; font-size: inherit,inherit] {23 [size=; font-size: inherit,inherit] $ni=imagecreate($ftoW,$ftoH);24 [size=; font-size: inherit,inherit] imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);25 [size=; font-size: inherit,inherit] }26 [size=; font-size: inherit,inherit] switch ($srcInfo[2])27 [size=; font-size: inherit,inherit] {28 [size=; font-size: inherit,inherit] case 1:29 [size=; font-size: inherit,inherit] imagegif($ni,$toFile);30 [size=; font-size: inherit,inherit] break;31 [size=; font-size: inherit,inherit] case 2:32 [size=; font-size: inherit,inherit] imagejpeg($ni,$toFile,100);33 [size=; font-size: inherit,inherit] break;34 [size=; font-size: inherit,inherit] case 3:35 [size=; font-size: inherit,inherit] imagepng($ni,$toFile);36 [size=; font-size: inherit,inherit] break;37 [size=; font-size: inherit,inherit] case 6:38 [size=; font-size: inherit,inherit] imagebmp($ni,$toFile);39 [size=; font-size: inherit,inherit] break;40 [size=; font-size: inherit,inherit] default:41 [size=; font-size: inherit,inherit] return false;42 [size=; font-size: inherit,inherit] }43 [size=; font-size: inherit,inherit] imagedestroy($ni);44 [size=; font-size: inherit,inherit] } ///45 46 $toWH=$toW/$toH;47 $srcWH=$srcW/$srcH;48 if($toWH<=$srcWH)49 {50 $ftoW=$toW;51 $ftoH=$ftoW*($srcH/$srcW);52 }53 else54 {55 $ftoH=$toH;56 $ftoW=$ftoH*($srcW/$srcH);57 }这样织梦上传的图,就不会显示x号了。
新闻热点
疑难解答