<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></title> 
<link>http://www.bizeway.net/index.php</link> 
<description><![CDATA[网务通 - 网务公司发展之路]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></copyright>
<item>
<link>http://www.bizeway.net/read.php?</link>
<title><![CDATA[PHP5文字图片混合水印与缩略图的原理]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[PHP]]></category>
<pubDate>Sun, 05 Dec 2010 05:15:18 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?</guid> 
<description>
<![CDATA[ 
	很多学生都在问我缩略图和打水印怎么做？就算我给了他们现成的功能类，他们也不能理解。这里我把缩略图的打水印主要用到的几个功能函数的中文解释写出来，供大家更好的学习。<br/><br/>1、介绍PHP水印原理和流程 <br/> &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 原始图片--》上传到dir --》 载入到内存 -》 PHP初始化 -》 水印处理 <br/> <br/>2、ImageCreateFrom* 图片载入函数 <br/> <br/> &nbsp; &nbsp; &nbsp;ImageCreateFrom* 载入内存是一个将图片文件载入内存供PHP使用的过程 <br/> <br/> &nbsp;<br/> &nbsp; &nbsp;imagecreatefromgif <br/> &nbsp; &nbsp;imagecreatefromjpeg <br/> &nbsp; &nbsp;imagecreatefrompng <br/> &nbsp; &nbsp;imagecreatefromwbmp <br/> &nbsp; &nbsp;imagecreatefromstring &nbsp; ： 通过一串图片编码 <br/> <br/> &nbsp;<br/>使用格式： <br/> &nbsp; &nbsp;imagecreatefromgif('php100.gif'); <br/> &nbsp; <br/>3、imagecopy 图片合并函数 <br/> &nbsp;<br/> &nbsp; &nbsp;imagecopy ( Dimg, Simg, int x, int y, int src_x, int src_y, int src_w, int src_h ) <br/> <br/>Dimg:被加水印的图片<br/>simg：水印图片<br/>x，y：显示在图片的位置（水印图片在图片的显示位置）<br/>src_x,src_y:水印图片从哪里开始显示<br/>src_w,src_h:水印图片的宽度和高度<br/> <br/> &nbsp;<br/>4、ImageCopyResized图片剪切函数 <br/> &nbsp; &nbsp; imagecopyresized ( resource dst_image, resource src_image, int dst_x,int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h ) <br/> <br/>dst_image:新图片<br/>src_image：原来的图片<br/>dst_x，dst_y：从什么地方开始对齐<br/>src_x，src_y：从哪里开始剪切<br/>int dst_w, int dst_h：新图的大小<br/>int src_w, int src_h：原始图的大小<br/> <br/> &nbsp;<br/>在使用剪切图之前我们需要先建立一个真彩图，也就是方便内存来存储 <br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">1.<?php &nbsp; <br/>2. &nbsp;<br/>3. &nbsp; &nbsp;$image="winter.jpg"; &nbsp; <br/>4. &nbsp;<br/>5. &nbsp; &nbsp;//取得图片的大小 &nbsp; <br/>6. &nbsp; &nbsp;$img=GetImageSize($image); &nbsp; <br/>7. &nbsp;<br/>8. &nbsp; &nbsp;//$img[2] 中存储的是图片的格式 &nbsp; <br/>9. &nbsp; &nbsp;swith($img[2]){ &nbsp; <br/>10. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case 1： &nbsp; <br/>11. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $im=@ImageCreateFormGIF($image); &nbsp; <br/>12. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp; <br/>13. &nbsp;<br/>14. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 2: &nbsp; <br/>15. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $im=@ImageCreateFormJPEG($image); &nbsp; <br/>16. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break; &nbsp; <br/>17. &nbsp;<br/>18. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 3: &nbsp; <br/>19. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $im=@ImageCreateFormPNG($image); &nbsp; <br/>20. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp; <br/>21. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; <br/>22. &nbsp; &nbsp;<br/>23. &nbsp; &nbsp;//文字水印 &nbsp; <br/>24. &nbsp; $tc=imagecolorallocate($im,255,255,255);//颜色 &nbsp; <br/>25. &nbsp; &nbsp; $str=iconv("gbk","utf-8","新年");//输出内容 &nbsp; <br/>26. &nbsp; &nbsp; imagettftext($im,12,0,20,20,$tc,'simhe1.ttf',$str);//写入图片 &nbsp; <br/>27. &nbsp; &nbsp;<br/>28. &nbsp;<br/>29. &nbsp;<br/>30.<!--第二个例子--> &nbsp; <br/>31. &nbsp;<br/>32. &nbsp; &nbsp; &nbsp;//图片水印 &nbsp; <br/>33. &nbsp; &nbsp;$log="1.jpg"; &nbsp; <br/>34. &nbsp; &nbsp; &nbsp;$l=GetImageSize($log); &nbsp; <br/>35. &nbsp; &nbsp;<br/>36. &nbsp; &nbsp; &nbsp; swith($l2]){ &nbsp; <br/>37. &nbsp;<br/>38. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case 1: &nbsp; <br/>39. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $in=@ImageCreateFormGIF($log); &nbsp; <br/>40. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break; &nbsp; <br/>41. &nbsp;<br/>42. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case 2: &nbsp; <br/>43. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$in=@ImageCreateFormJPEG($log); &nbsp; <br/>44. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp; <br/>45. &nbsp;<br/>46. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 3: &nbsp; <br/>47. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$in=@ImageCreateFormPNG($log); &nbsp; <br/>48. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break; &nbsp; <br/>49. &nbsp;<br/>50. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; <br/>51. &nbsp;<br/>52. &nbsp; &nbsp; //图片合并 &nbsp; <br/>53. &nbsp; &nbsp; &nbsp;imagecopy($im,$in,400,50，0，0，"120","345"); &nbsp; <br/>54. &nbsp;<br/>55. &nbsp; //输出图片 &nbsp; <br/>56. &nbsp; &nbsp;imageJpeg($im,"新图"); &nbsp; <br/>57. &nbsp; &nbsp;<br/>58.//剪切 &nbsp; <br/>59. &nbsp;<br/>60.//首先建议一个空的真彩图 &nbsp; <br/>61. $new=ImageCreateTrueColor(500,500); &nbsp; <br/>62. &nbsp; &nbsp;<br/>63. //ImageCopyResized图片剪切函数 &nbsp; &nbsp;<br/>64. &nbsp; &nbsp;imagecopyresized ( resource dst_image, resource src_image, int &nbsp; dst_x,int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h ) &nbsp; &nbsp;<br/>65. &nbsp;<br/>66. &nbsp;<br/>67.?> &nbsp; </div></div><br/>Tags - <a href="tag.php?tag=php" rel="tag">php</a> , <a href="tag.php?tag=%E7%BC%A9%E7%95%A5%E5%9B%BE" rel="tag">缩略图</a> , <a href="tag.php?tag=%E6%B0%B4%E5%8D%B0" rel="tag">水印</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?&amp;guid=0#topreply</link>
<title><![CDATA[[评论] PHP5文字图片混合水印与缩略图的原理]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?&amp;guid=0#topreply</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>