PHP implements the example code of image rotation effect
PHP rotation of images
<div> <h4>Before rotation</h4> <img src="" style="border:1px solid red;"> </div> <?php header("content-type","text/html;charset=utf-8"); /* *The picture rotates along the y-axis, taking the png format as an example *@param string $filename url of image */ function turn_y($filename) { /*Create image resources*/ $backy = imagecreatefrompng($filename); /*Get the size*/ $widthy = imagesx($backy); $heighty = imagesy($backy); /*Create a new image resource and save the flipped image*/ $newy = imagecreatetruecolor($widthy, $heighty); /*Flip along the y-axis, which means copying the original image from right to left to one pixel width to the new resource one by one*/ for ($i=0; $i < $widthy; $i++) { imagecopy($newy,$backy,$widthy-$i-1,0,$i,0,1,$heighty); } /*Save the flipped image*/ imagepng($newy,''); /*Release resources*/ imagedestroy($backy); imagedestroy($newy); } /* *The picture rotates along the x-axis, taking the png format as an example *@param string $filename url of image */ function turn_x($filename) { /*Create image resources*/ $backx = imagecreatefrompng($filename); /*Get the size*/ $widthx = imagesx($backx); $heightx = imagesy($backx); /*Create a new image resource and save the flipped image*/ $newx = imagecreatetruecolor($widthx, $heightx); /*Flip along the x-axis, which means copying the original image from top to bottom one pixel width to the new resource one by one*/ for ($i=0; $i < $heightx; $i++) { imagecopy($newx,$backx,0,$heightx-$i-1,0,$i,$widthx,1); } /*Save the flipped image*/ imagepng($newx,''); /*Release resources*/ imagedestroy($backx); imagedestroy($newx); } /*Calling function*/ turn_y(''); turn_x(''); ?> <div style="float:left"> <h4>AlongyAxis rotation</h4> <img src="" style="border:1px solid red;"> </div> <div style="float:left"> <h4>AlongxAxis rotation</h4> <img src="" style="border:1px solid red;"> </div>
Related Articles
ThinkPHP 3.2.2 Methods to implement transaction operations
This article mainly introduces the methods of implementing transaction operations in ThinkPHP 3.2.2. It simply analyzes the operation methods of starting, committing, rolling back and other transactions in thinkPHP and gives a complete transaction commit and rolling back operation example. Friends who need it can refer to it.2017-05-05Install and configure Nginx server + PHP development environment from scratch under Linux
This article mainly introduces the tutorial on installing and configuring the Nginx server + PHP development environment from scratch under Linux. The article uses the most mainstream FastCGI connection method. Friends who need it can refer to it.2015-12-12Methods for developing WeChat public platform to realize 2048 games
This article mainly introduces the methods of developing WeChat public platform to realize 2048 games. It tells more details about the principles of 2048 games and the skills of developing WeChat public platform to develop 2048 games. It is very practical. Friends who need it can refer to it.2015-04-04PHP Cartesian product implementation principle and code example
This article mainly introduces the implementation principle and code examples of PHP Cartesian product. The article introduces the example code in detail, which has certain reference learning value for everyone's learning or work. Friends who need it can refer to it.2020-12-12php method to get array length (example)
php method to get the length of an array. php provides us with two functions that can calculate the length of a one-dimensional array. For example, count and sizeof can directly count the length of an array, and also a method to get a two-dimensional array.2013-10-10The Practical Process of Exception Handling in Core Interpretation of Laravel
This article mainly introduces relevant materials on the core interpretation of Laravel's exception handling. The example code is introduced in this article in detail, which has certain reference learning value for everyone's study or work. Friends who need it, let's study together.2019-02-02thinkPHP3.2.3 method to implement Alibaba's greater than SMS verification
This article mainly introduces the method of thinkingPHP3.2.3 to implement Alibaba's greater than SMS verification. It is very good and has certain reference value. Friends who need it can refer to it.2018-06-06Comparison of the difference between file_get_contents('php://input') and $_POST
This article mainly introduces the comparison of the difference between php using file_get_contents('php://input') and $_POST. This knowledge point is relatively commonly used. If you need it, please refer to it.2021-03-03Analysis of common code examples for PHP sdk document processing
This article mainly introduces the analysis of common code examples of PHP sdk document processing. The example code is introduced in this article in detail, which has certain reference value for everyone's study or work. Friends who need it can refer to it.2020-12-12Tutorial on integrating Alipay payment function under the ThinkPHP framework
This article mainly introduces the integration of Alipay payment functions under the ThinkPHP framework, and analyzes the related configuration methods, operation techniques and related precautions of the thinkPHP framework integrates Alipay payment function interface in detail in combination with the graphics and text form. Friends who need it can refer to it.2019-04-04