php图像处理函数大全(推荐收藏)(2)


<?PHP
 /**
 *
 * 图片添加文字水印
 */

 function mark_text($background, $text, $x, $y){
 $back=imagecreatefromjpeg($background);
 $color=imagecolorallocate($back, 0, 255, 0);
 imagettftext($back, 20, 0, $x, $y, $color, "simkai.ttf", $text);
 imagejpeg($back, "./images/hee7.jpg");
 imagedestroy($back);
 }
 mark_text("./images/hee.jpg", "细说PHP", 150, 250);
 //图片水印
 function mark_pic($background, $waterpic, $x, $y){
 $back=imagecreatefromjpeg($background);
 $water=imagecreatefromgif($waterpic);
 $w_w=imagesx($water);
 $w_h=imagesy($water);
 imagecopy($back, $water, $x, $y, 0, 0, $w_w, $w_h);
 imagejpeg($back,"./images/hee8.jpg");
 imagedestroy($back);
 imagedestroy($water);
 }
 mark_pic("./images/hee.jpg", "./images/gaolf.gif", 50, 200);


图片旋转

复制代码 代码如下:


<?PHP
 /**
 * 图片旋转
 */
 $back=imagecreatefromjpeg("./images/hee.jpg");

 $new=imagerotate($back, 45, 0);
 imagejpeg($new, "./images/hee9.jpg");
 ?>


图片水平翻转垂直翻转

复制代码 代码如下:


<?php
 /**
 * 图片水平翻转 垂直翻转
 */
 function turn_y($background, $newfile){
 $back=imagecreatefromjpeg($background);
 $width=imagesx($back);
 $height=imagesy($back);
 $new=imagecreatetruecolor($width, $height);
 for($x=0; $x < $width; $x++){
 imagecopy($new, $back, $width-$x-1, 0, $x, 0, 1, $height);
 }
 imagejpeg($new, $newfile);
 imagedestroy($back);
 imagedestroy($new);
 }
 function turn_x($background, $newfile){
 $back=imagecreatefromjpeg($background);
 $width=imagesx($back);
 $height=imagesy($back);
 $new=imagecreatetruecolor($width, $height);
 for($y=0; $y < $height; $y++){
 imagecopy($new, $back,0, $height-$y-1, 0, $y, $width, 1);
 }
 imagejpeg($new, $newfile);
 imagedestroy($back);
 imagedestroy($new);
 }
 turn_y("./images/hee.jpg", "./images/hee11.jpg");
 turn_x("./images/hee.jpg", "./images/hee12.jpg");
 ?>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/4a11745e16d6a9974f07d7f787b10ace.html