PHP Image manipulation: 3D graph, zoom, rotate, crop, add watermark (iii)

Source: Internet
Author: User
Tags imagecopy

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.