码迷,mamicode.com
首页 > 其他好文 > 详细

对图片进行翻转

时间:2015-11-24 14:20:04      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
 1 <?php
 2     function turn_y($filename){
 3         $image_back = imagecreatefromjpeg($filename);
 4         
 5         $width = imagesx($image_back);
 6         $height = imagesy($image_back);
 7         
 8         $image_new = imagecreatetruecolor($width,$height);
 9         
10         for($x = 0;$x < $width;$x ++){
11             imagecopy($image_new,$image_back,$width - $x - 1,0,$x,0,1,$height);
12         }
13         
14         imagejpeg($image_new,$filename);
15         
16         imagedestroy($image_back);
17         imagedestroy($image_new);
18     }
19     
20     function turn_x($filename){
21         $image_back = imagecreatefromjpeg($filename);
22         
23         $width = imagesx($image_back);
24         $height = imagesy($image_back);
25         
26         $image_new = imagecreatetruecolor($width,$height);
27         
28         for($y = 0;$y < $height;$y ++){
29             imagecopy($image_new,$image_back,0,$height - $y - 1,0,$y,$width,1);
30         }
31         
32         imagejpeg($image_new,$filename);
33         
34         imagedestroy($image_back);
35         imagedestroy($image_new);
36     }
37     
38     turn_x("mm2.jpeg");
39 ?>
turn_y turn_x

 

对图片进行翻转

标签:

原文地址:http://www.cnblogs.com/banshaohuan/p/4991267.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!