<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>长沙我心飞扬seo &#187; dedecms缩略图</title>
	<atom:link href="http://www.wxfy.net/tag/dedecms%e7%bc%a9%e7%95%a5%e5%9b%be/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wxfy.net</link>
	<description>长沙seo,长沙网站建设,长沙网站优化首选我心飞扬seo</description>
	<lastBuildDate>Tue, 31 Aug 2010 01:50:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>dedecms缩略图智能生成方式</title>
		<link>http://www.wxfy.net/a-way-to-buide-dedecms-thumbnail/</link>
		<comments>http://www.wxfy.net/a-way-to-buide-dedecms-thumbnail/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 11:47:35 +0000</pubDate>
		<dc:creator>阿非</dc:creator>
				<category><![CDATA[心情随笔]]></category>
		<category><![CDATA[dede]]></category>
		<category><![CDATA[dedecms]]></category>
		<category><![CDATA[dedecms智能缩略图]]></category>
		<category><![CDATA[dedecms缩略图]]></category>

		<guid isPermaLink="false">http://www.wxfy.net/?p=118</guid>
		<description><![CDATA[dedecms自动生成的缩略图片是根据自定义的最大长宽，原比例的缩小原图片，因此生成的每张缩略图可能高度都不相同，因此可以修改一下缩略图生成方式，智能生成指定大小的缩略图。
首先dedecms5.3:
 
修改如下：
打开/includes/image.func.php文件，找到方法function ImageResize()，用下面的代码覆盖（注意备份喔）。
新方法ImageResize()
function ImageResize($srcFile,$toW,$toH,$toFile=&#8221;")
{
global $cfg_photo_type;
if($toFile==&#8221;")
{
$toFile = $srcFile;
}
$info = &#8220;&#8221;;
$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&#60;=$toW &#38;&#38; $srcH&#60;=$toH )
{
return true;
}
//缩略生成并裁剪
$newW = $toH * $srcW / $srcH;
$newH = $toW * $srcH / $srcW;
if($newH &#62;= $toH)
{
$ftoW = $toW;
$ftoH = $newH;
}
else
{
$ftoW = $newW;
$ftoH = $toH;
}
if($srcW&#62;$toW&#124;&#124;$srcH&#62;$toH)
{
if(function_exists(&#8221;imagecreatetruecolor&#8221;))
{
@$ni = [...]]]></description>
			<content:encoded><![CDATA[<p>dedecms自动生成的缩略图片是根据自定义的最大长宽，原比例的缩小原图片，因此生成的每张缩略图可能高度都不相同，因此可以修改一下缩略图生成方式，智能生成指定大小的缩略图。</p>
<p><strong><span id="more-118"></span>首先dedecms5.3:</strong></p>
<p><strong> </strong></p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">修改如下：</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">打开/includes/image.func.php文件，找到方法function ImageResize()，用下面的代码覆盖（注意备份喔）。</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">新方法ImageResize()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">function ImageResize($srcFile,$toW,$toH,$toFile=&#8221;")</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">global $cfg_photo_type;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if($toFile==&#8221;")</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$toFile = $srcFile;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$info = &#8220;&#8221;;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$srcInfo = GetImageSize($srcFile,$info);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">switch ($srcInfo[2])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case 1:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if(!$cfg_photo_type['gif'])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return false;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$im = imagecreatefromgif($srcFile);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case 2:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if(!$cfg_photo_type['jpeg'])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return false;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$im = imagecreatefromjpeg($srcFile);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case 3:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if(!$cfg_photo_type['png'])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return false;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$im = imagecreatefrompng($srcFile);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case 6:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if(!$cfg_photo_type['bmp'])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return false;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$im = imagecreatefromwbmp($srcFile);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$srcW=ImageSX($im);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$srcH=ImageSY($im);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if($srcW&lt;=$toW &amp;&amp; $srcH&lt;=$toH )</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return true;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">//缩略生成并裁剪</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$newW = $toH * $srcW / $srcH;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$newH = $toW * $srcH / $srcW;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if($newH &gt;= $toH)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$ftoW = $toW;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$ftoH = $newH;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">else</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$ftoW = $newW;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$ftoH = $toH;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if($srcW&gt;$toW||$srcH&gt;$toH)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if(function_exists(&#8221;imagecreatetruecolor&#8221;))</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@$ni = imagecreatetruecolor($ftoW,$ftoH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if($ni)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">else</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$ni=imagecreate($ftoW,$ftoH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">else</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$ni=imagecreate($ftoW,$ftoH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">//裁剪图片成标准缩略图</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">$new_imgx = imagecreatetruecolor($toW,$toH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if($newH &gt;= $toH)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagecopyresampled($new_imgx,$ni,0,0,0,($newH &#8211; $toH)/2,$toW,$toH,$toW,$toH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">else</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagecopyresampled($new_imgx,$ni,0,0,($newW &#8211; $toW)/2,0,$toW,$toH,$toW,$toH);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">switch ($srcInfo[2])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case 1:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagegif($new_imgx,$toFile);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case 2:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagejpeg($new_imgx,$toFile,85);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case 3:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagepng($new_imgx,$toFile);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">case 6:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagebmp($new_imgx,$toFile);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">break;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">default:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return false;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagedestroy($new_imgx);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagedestroy($ni);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">imagedestroy($im);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return true;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<blockquote>
<p>打开/includes/image.func.php文件，找到方法function ImageResize()，用下面的代码覆盖（注意备份）。</p>
<p>function ImageResize($srcFile,$toW,$toH,$toFile=&#8221;")</p>
<p>{</p>
<p>global $cfg_photo_type;</p>
<p>if($toFile==&#8221;")</p>
<p>{</p>
<p>$toFile = $srcFile;</p>
<p>}</p>
<p>$info = &#8220;&#8221;;</p>
<p>$srcInfo = GetImageSize($srcFile,$info);</p>
<p>switch ($srcInfo[2])</p>
<p>{</p>
<p>case 1:</p>
<p>if(!$cfg_photo_type['gif'])</p>
<p>{</p>
<p>return false;</p>
<p>}</p>
<p>$im = imagecreatefromgif($srcFile);</p>
<p>break;</p>
<p>case 2:</p>
<p>if(!$cfg_photo_type['jpeg'])</p>
<p>{</p>
<p>return false;</p>
<p>}</p>
<p>$im = imagecreatefromjpeg($srcFile);</p>
<p>break;</p>
<p>case 3:</p>
<p>if(!$cfg_photo_type['png'])</p>
<p>{</p>
<p>return false;</p>
<p>}</p>
<p>$im = imagecreatefrompng($srcFile);</p>
<p>break;</p>
<p>case 6:</p>
<p>if(!$cfg_photo_type['bmp'])</p>
<p>{</p>
<p>return false;</p>
<p>}</p>
<p>$im = imagecreatefromwbmp($srcFile);</p>
<p>break;</p>
<p>}</p>
<p>$srcW=ImageSX($im);</p>
<p>$srcH=ImageSY($im);</p>
<p>if($srcW&lt;=$toW &amp;&amp; $srcH&lt;=$toH )</p>
<p>{</p>
<p>return true;</p>
<p>}</p>
<p>//缩略生成并裁剪</p>
<p>$newW = $toH * $srcW / $srcH;</p>
<p>$newH = $toW * $srcH / $srcW;</p>
<p>if($newH &gt;= $toH)</p>
<p>{</p>
<p>$ftoW = $toW;</p>
<p>$ftoH = $newH;</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>$ftoW = $newW;</p>
<p>$ftoH = $toH;</p>
<p>}</p>
<p>if($srcW&gt;$toW||$srcH&gt;$toH)</p>
<p>{</p>
<p>if(function_exists(&#8221;imagecreatetruecolor&#8221;))</p>
<p>{</p>
<p>@$ni = imagecreatetruecolor($ftoW,$ftoH);</p>
<p>if($ni)</p>
<p>{</p>
<p>imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>$ni=imagecreate($ftoW,$ftoH);</p>
<p>imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);</p>
<p>}</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>$ni=imagecreate($ftoW,$ftoH);</p>
<p>imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);</p>
<p>}</p>
<p>//裁剪图片成标准缩略图</p>
<p>$new_imgx = imagecreatetruecolor($toW,$toH);</p>
<p>if($newH &gt;= $toH)</p>
<p>{</p>
<p>imagecopyresampled($new_imgx,$ni,0,0,0,($newH &#8211; $toH)/2,$toW,$toH,$toW,$toH);</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>imagecopyresampled($new_imgx,$ni,0,0,($newW &#8211; $toW)/2,0,$toW,$toH,$toW,$toH);</p>
<p>}</p>
<p>switch ($srcInfo[2])</p>
<p>{</p>
<p>case 1:</p>
<p>imagegif($new_imgx,$toFile);</p>
<p>break;</p>
<p>case 2:</p>
<p>imagejpeg($new_imgx,$toFile,85);</p>
<p>break;</p>
<p>case 3:</p>
<p>imagepng($new_imgx,$toFile);</p>
<p>break;</p>
<p>case 6:</p>
<p>imagebmp($new_imgx,$toFile);</p>
<p>break;</p>
<p>default:</p>
<p>return false;</p>
<p>}</p>
<p>imagedestroy($new_imgx);</p>
<p>imagedestroy($ni);</p>
<p>}</p>
<p>imagedestroy($im);</p>
<p>return true;</p></blockquote>
<blockquote><p>}</p></blockquote>
<p><strong>另外附上dedecms5.5的：</strong></p>
<blockquote>
<p>修改文件：image.func.php（或inc_photograph.php）</p>
<p>if($toWH&lt;=$srcWH){</p>
<p>$ftoW=$toW;</p>
<p>$ftoH=$ftoW*($srcH/$srcW);</p>
<p>}</p>
<p>else{</p>
<p>$ftoH=$toH;</p>
<p>$ftoW=$ftoH*($srcW/$srcH);</p>
<p>}</p>
<p>更改为</p>
<p>$ftoH=$toH;</p>
<p>$ftoW=$toW;</p>
<p>if ($toWH&lt;=$srcWH) {</p>
<p>$src_Y = 0;</p>
<p>$src_X = ($srcW-$srcH*$toWH)/2;</p>
<p>$srcW = $srcH*$toWH;</p>
<p>} else {</p>
<p>$src_X = 0;</p>
<p>$src_Y = ($srcH-$srcW/$toWH)/2;</p>
<p>$srcH = $srcW/$toWH;</p>
<p>}</p>
<p>($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH)</p>
<p>更改为</p>
<p>($ni,$im,0,0,$src_X,$src_Y,$ftoW,$ftoH,$srcW,$srcH)</p>
<p>其实就一小小改动，就是在原图中截取最大面积的符合自定义缩略图长宽比列的一部分生成缩略图。</p></blockquote>
<p><strong> </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.wxfy.net/a-way-to-buide-dedecms-thumbnail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
