Dede縮略圖不變形的解決辦法,織夢文章
導讀:織夢文章織夢文章打開/includes/image.func.php文件, //縮圖片自動生成函數,來源支持bmp、gif、jpg、png //但生成的小圖只用jpg或png格織夢文章模板。
打開/includes/image.func.php文件, //縮圖片自動生成函數,來源支持bmp、gif、jpg、png //但生成的小圖只用jpg或png格式 找到代碼第44行function ImageResize 至 //獲得GD的版本之間的代碼 用如下的代碼覆蓋即可
function ImageResize($srcFile,$toW,$toH,$toFile="")
{ global $cfg_photo_type; if($toFile=="") { $toFile = $srcFile; } $info = ""; $srcInfo = GetImageSize($srcFile,$info); switch ($srcInfo[2]) { case 1: if(!$cfg_photo_type['gif']) { return false; } $im = imagecreatefromgif($srcFile); break; case 2: if(!$cfg_photo_type['jpeg']) { return false; } $im = imagecreatefromjpeg($srcFile); break; case 3: if(!$cfg_photo_type['png']) { return false; }
$im = imagecreatefrompng($srcFile); break; case 6: if(!$cfg_photo_type['bmp']) { return false; } $im = imagecreatefromwbmp($srcFile); break; } $srcW=ImageSX($im); $srcH=ImageSY($im); if($srcW<=$toW && $srcH<=$toH ) { return true; } //縮略生成并裁剪 $newW = $toH * $srcW / $srcH; &ndede模板堂bsp; $newH = $toW * $srcH / $srcW; if($newH >= $toH) { $ftoW = $toW; $ftoH = $newH; } else { $ftoW = $newW; $ftoH = $toH; } if($srcW>$toW||$srcH>$toH) { if(function_exists("imagecreatetruecolor")) { @$ni = imagecreatetruecolor($ftoW,$ftoH); if($ni) { imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); } else { $ni=imagecreate($ftoW,$ftoH); imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); } } else { $ni=imagecreate($ftoW,$ftoH); imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH); } //裁剪圖片成標準縮略圖 $new_imgx = imagecreatetruecolor($toW,$toH); if($newH >= $toH) { imagecopyresampled($織夢的模板new_imgx,$ni,0,0,0,($newH - $toH)/2,$toW,$toH,$toW,$toH); } else { imagecopyresampled($new_imgx,$ni,0,0,($newW - $toW)/2,0,$toW,$toH,$toW,$toH); } switch ($srcInfo[2]) { case 1: imagegif($new_imgx,$toFile); break; case 2: imagejpeg($new_imgx,$toFile,85); break; case 3: imagepng($new_imgx,$toFile); break; case 6: imagebmp($new_imgx,$toFile); break; default: return false; } imagedestroy($new_imgx); imagedestroy($ni); } imagedestroy($im); return true; }
聲明: 本文由我的SEOUC技術文章主頁發布于:2023-07-22 ,文章Dede縮略圖不變形的解決辦法,織夢文章主要講述解決辦法,縮略圖,織夢網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_34297.html