Source: http://www.ido321.com/887.html
5, PHP rotation of the image
1: <div>
2:
3: <img src="1.png" style= "border:1px solid red;" >
4: </div>
5: <?php
6: header ("Content-type","Text/html;charset=utf-8");
7:
8:/*
9:* Picture is rotated along the y-axis, for example in PNG format
:* @param string $filename The URL of the picture
One :* *
:function turn_y ($filename)
: {
* / * Create a picture resource * /
: $backy = imagecreatefrompng ($filename);
16:
* / * Get size * /
: $widthy = Imagesx ($backy);
: $heighty = Imagesy ($backy);
20:
* / * Create a new picture resource, save the flipped picture * /
: $newy = Imagecreatetruecolor ($widthy, $heighty);
23:
+ / * Flips along the y-axis, copying the original image from right to left by one pixel width to the new resource individually * /
:for
: imagecopy ($newy, $backy, $widthy-$i -1,0, $i, 0,1, $heighty);
: }
28:
* / * Save the flipped picture * /
: imagepng ($newy,' test3.png ');
31:
* / * FREE resources * /
: Imagedestroy ($backy);
: Imagedestroy ($newy);
: }
36:
Notoginseng:/*
* :* Picture is rotated along the x-axis, for example in PNG format
In :* @param the URL of a string $filename picture
Max :* /
In :function turn_x ($filename)
: {
* / * Create a picture resource * /
: $backx = imagecreatefrompng ($filename);
45:
* / * Get size * /
A : $widthx = Imagesx ($backx);
: $heightx = Imagesy ($backx);
49:
* / * Create a new picture resource, save the flipped picture * /
Wuyi: $newx = Imagecreatetruecolor ($widthx, $heightx);
52:
-*/* flips along the x-axis, copying the original image from top to bottom by one pixel width to the new resource individually * /
Si :for
: imagecopy ($newx, $backx, 0, $heightx-$i -1,0, $i, $WIDTHX, 1);
: }
57:
* / * Save the flipped picture * /
: imagepng ($newx,' test4.png ');
60:
A :/ * Release resources * /
: Imagedestroy ($backx);
A : Imagedestroy ($newx);
: }
* /* Call function * /
: turn_y (' 1.png ');
: turn_x (' 1.png ');
: ?>
: <div style="Float:left">
X :
: <img src="test3.png" style= "border:1px solid red;" >
: </div>
: <div style="Float:left">
:
: <img src="test4.png" style= "border:1px solid red;" >
: </div>
Effect
PHP Image manipulation: 3D graph, zoom, rotate, crop, add watermark (iii)