<?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>代码收藏 &#187; 缩略图</title> <atom:link href="http://code.9enjoy.com/tag/%e7%bc%a9%e7%95%a5%e5%9b%be/feed/" rel="self" type="application/rss+xml" /><link>http://code.9enjoy.com</link> <description>收集网站开发时常用到的代码(asp,php,js等)，以函数为主</description> <lastBuildDate>Mon, 24 Jan 2011 14:23:49 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.1</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>thumb-创建图片缩略图</title><link>http://code.9enjoy.com/php/thumb-%e5%88%9b%e5%bb%ba%e5%9b%be%e7%89%87%e7%bc%a9%e7%95%a5%e5%9b%be/</link> <comments>http://code.9enjoy.com/php/thumb-%e5%88%9b%e5%bb%ba%e5%9b%be%e7%89%87%e7%bc%a9%e7%95%a5%e5%9b%be/#comments</comments> <pubDate>Thu, 27 Mar 2008 14:33:35 +0000</pubDate> <dc:creator>enjoy</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[缩略图]]></category><guid
isPermaLink="false">http://code.itlearner.com/?p=23</guid> <description><![CDATA[[CODE_LITE]/**<br/> * 创建图片缩略图,成功返回真<br/> *<br/> * @param string $cat      目录<br/> * @param string $oldname  原图文件名<br/> * @param string $newname  新图文件名<br/> * @param int $width       缩略图宽<br/> * @param int $height      缩略图高<br/> * @return <br/> */<br/>function thumb($cat,$oldname,$newname,$width=160,$height=120){<br/>...
]]></description> <content:encoded><![CDATA[<p
class="code"><code>/**<br/>&nbsp;&nbsp;*&nbsp;创建图片缩略图,成功返回真<br/>&nbsp;&nbsp;*<br/>&nbsp;&nbsp;*&nbsp;@param&nbsp;string&nbsp;$cat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;目录<br/>&nbsp;&nbsp;*&nbsp;@param&nbsp;string&nbsp;$oldname&nbsp;&nbsp;原图文件名<br/>&nbsp;&nbsp;*&nbsp;@param&nbsp;string&nbsp;$newname&nbsp;&nbsp;新图文件名<br/>&nbsp;&nbsp;*&nbsp;@param&nbsp;int&nbsp;$width&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;缩略图宽<br/>&nbsp;&nbsp;*&nbsp;@param&nbsp;int&nbsp;$height&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;缩略图高<br/>&nbsp;&nbsp;*&nbsp;@return&nbsp;<br/>&nbsp;&nbsp;*/<br/>function&nbsp;thumb($cat,$oldname,$newname,$width=160,$height=120){<br/>&nbsp;&nbsp;$srcFile&nbsp;=&nbsp;$cat.&nbsp;"/"&nbsp;.$oldname;<br/>&nbsp;&nbsp;$data&nbsp;=&nbsp;getimagesize($srcFile);<br/>&nbsp;&nbsp;$dscFile&nbsp;=&nbsp;$cat.&nbsp;"/".&nbsp;$newname;<br/><br/>&nbsp;&nbsp;&nbsp;switch&nbsp;($data[2])&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;1:<br/>&nbsp;&nbsp;&nbsp;&nbsp;$im&nbsp;=&nbsp;imagecreatefromgif($srcFile);<br/>&nbsp;&nbsp;&nbsp;&nbsp;break;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;2:<br/>&nbsp;&nbsp;&nbsp;&nbsp;$im&nbsp;=&nbsp;imagecreatefromjpeg($srcFile);<br/>&nbsp;&nbsp;&nbsp;&nbsp;break;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;3:<br/>&nbsp;&nbsp;&nbsp;&nbsp;$im&nbsp;=&nbsp;imagecreatefrompng($srcFile);<br/>&nbsp;&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;&nbsp;}<br/><br/>&nbsp;&nbsp;&nbsp;$srcW=imagesx($im);<br/>&nbsp;&nbsp;&nbsp;$srcH=imagesy($im);<br/><br/>&nbsp;&nbsp;&nbsp;if(($srcW/$width)&gt;=($srcH/$height)){<br/>&nbsp;&nbsp;&nbsp;&nbsp;$temp_height=$height;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$temp_width=$srcW/($srcH/$height);<br/>&nbsp;&nbsp;&nbsp;&nbsp;$src_X=abs(($width-$temp_width)/2);<br/>&nbsp;&nbsp;&nbsp;&nbsp;$src_Y=0;<br/>&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;&nbsp;else{<br/>&nbsp;&nbsp;&nbsp;&nbsp;$temp_width=$width;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$temp_height=$srcH/($srcW/$width);<br/>&nbsp;&nbsp;&nbsp;&nbsp;$src_X=0;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$src_Y=abs(($height-$temp_height)/2);<br/>&nbsp;&nbsp;&nbsp;}<br/><br/>&nbsp;&nbsp;&nbsp;$temp_img=imagecreatetruecolor($temp_width,$temp_height);<br/>&nbsp;&nbsp;&nbsp;imagecopyresized($temp_img,$im,0,0,0,0,$temp_width,$temp_height,$srcW,$srcH);<br/><br/>&nbsp;&nbsp;&nbsp;$ni=imagecreatetruecolor($width,$height);<br/>&nbsp;&nbsp;&nbsp;imagecopyresized($ni,$temp_img,0,0,$src_X,$src_Y,$width,$height,$width,$height);<br/>&nbsp;&nbsp;&nbsp;$cr&nbsp;=&nbsp;imagejpeg($ni,$dscFile);<br/><br/>&nbsp;&nbsp;&nbsp;if&nbsp;($cr){<br/>&nbsp;&nbsp;&nbsp;&nbsp;chmod($dscFile,&nbsp;0777);<br/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;true;<br/>&nbsp;&nbsp;&nbsp;}<br/>}</code></p> <img
src="http://code.9enjoy.com/?ak_action=api_record_view&id=23&type=feed" alt="" />]]></content:encoded> <wfw:commentRss>http://code.9enjoy.com/php/thumb-%e5%88%9b%e5%bb%ba%e5%9b%be%e7%89%87%e7%bc%a9%e7%95%a5%e5%9b%be/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>photoCreateCropThumb-生成图片缩略图</title><link>http://code.9enjoy.com/php/photocreatecropthumb-%e7%94%9f%e6%88%90%e5%9b%be%e7%89%87%e7%bc%a9%e7%95%a5%e5%9b%be/</link> <comments>http://code.9enjoy.com/php/photocreatecropthumb-%e7%94%9f%e6%88%90%e5%9b%be%e7%89%87%e7%bc%a9%e7%95%a5%e5%9b%be/#comments</comments> <pubDate>Thu, 27 Mar 2008 14:30:46 +0000</pubDate> <dc:creator>enjoy</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[缩略图]]></category><guid
isPermaLink="false">http://code.itlearner.com/?p=22</guid> <description><![CDATA[[CODE_LITE]<br/>function photoCreateCropThumb ($p_thumb_file, $p_photo_file, $p_max_size, $p_quality = 75) {<br/> <br/> $pic = @imagecreatefromjpeg($p_photo_file);<br/><br/> if ($pic) {<br/> $thumb = @imagecreatetruecolor ($p_max_size, $p_max_size) or die ("Can't create Image!");<br/>...
]]></description> <content:encoded><![CDATA[<p
class="code"><code>function&nbsp;photoCreateCropThumb&nbsp;($p_thumb_file,&nbsp;$p_photo_file,&nbsp;$p_max_size,&nbsp;$p_quality&nbsp;=&nbsp;75)&nbsp;{<br/>&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;$pic&nbsp;=&nbsp;@imagecreatefromjpeg($p_photo_file);<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($pic)&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$thumb&nbsp;=&nbsp;@imagecreatetruecolor&nbsp;($p_max_size,&nbsp;$p_max_size)&nbsp;or&nbsp;die&nbsp;("Can't&nbsp;create&nbsp;Image!");<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$width&nbsp;=&nbsp;imagesx($pic);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$height&nbsp;=&nbsp;imagesy($pic);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($width&nbsp;&lt;&nbsp;$height)&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$twidth&nbsp;=&nbsp;$p_max_size;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$theight&nbsp;=&nbsp;$twidth&nbsp;*&nbsp;$height&nbsp;/&nbsp;$width;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;imagecopyresized($thumb,&nbsp;$pic,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;($height/2)-($width/2),&nbsp;$twidth,&nbsp;$theight,&nbsp;$width,&nbsp;$height);&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$theight&nbsp;=&nbsp;$p_max_size;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$twidth&nbsp;=&nbsp;$theight&nbsp;*&nbsp;$width&nbsp;/&nbsp;$height;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;imagecopyresized($thumb,&nbsp;$pic,&nbsp;0,&nbsp;0,&nbsp;($width/2)-($height/2),&nbsp;0,&nbsp;$twidth,&nbsp;$theight,&nbsp;$width,&nbsp;$height);&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ImageJPEG&nbsp;($thumb,&nbsp;$p_thumb_file,&nbsp;$p_quality);<br/>&nbsp;&nbsp;&nbsp;&nbsp;}<br/><br/>}</code></p> <img
src="http://code.9enjoy.com/?ak_action=api_record_view&id=22&type=feed" alt="" />]]></content:encoded> <wfw:commentRss>http://code.9enjoy.com/php/photocreatecropthumb-%e7%94%9f%e6%88%90%e5%9b%be%e7%89%87%e7%bc%a9%e7%95%a5%e5%9b%be/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk
Database Caching 6/14 queries in 0.014 seconds using disk

Served from: code.itlearner.com @ 2012-02-07 03:05:19 -->
