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

Source: Internet
Author: User
Tags imagecopy

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


Source: http://www.ido321.com/887.html

5, PHP rotation of the image

   
   2:     

Before rotation

   3:     
   
5:
 
   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
  11: */
  12:function turn_y ($filename)
  13: {
  */     * 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 */
  25:     
  :         imagecopy ($newy, $backy, $widthy-$i -1,0, $i, 0,1, $heighty);
  :     }
  28:  
  */     * Save the flipped picture */
  :     imagepng ($newy, ' http://www.bkjia.com/uploads/allimg/141009/0425435558-1.png ');
  31:  
  */     * FREE resources */
  :     Imagedestroy ($backy);
  :     Imagedestroy ($newy);
  35:}
  36:  
  37:/*
  38: * Picture is rotated along the x-axis, for example in PNG format
  In: * @param the URL of a string $filename picture
  40: */
  41:function turn_x ($filename)
  42: {
  */     * 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 */
  54:     
  :         imagecopy ($newx, $backx, 0, $heightx-$i -1,0, $i, $WIDTHX, 1);
  :     }
  57:  
  */     * Save the flipped picture */
  :     imagepng ($newx, ' http://www.bkjia.com/uploads/allimg/141009/0425432228-2.png ');
  60:  
  A:/     * Release resources */
  :     Imagedestroy ($backx);
  A:     Imagedestroy ($NEWX);
  64:}
  65:/* Call function */
  66:turn_y (' http://www.bkjia.com/uploads/allimg/141009/0425435O8-0.png ');
  67:turn_x (' http://www.bkjia.com/uploads/allimg/141009/0425435O8-0.png ');
  :?>
  
  70:     

Rotate along the y axis

  71:     
  
  
  74:     

Rotate along the x axis

  75:     
  

Effect


http://www.bkjia.com/PHPjc/890204.html www.bkjia.com true http://www.bkjia.com/PHPjc/890204.html techarticle php Image manipulation: 3D graph, zoom, rotate, crop, add watermark (c) Source: http://www.ido321.com/887.html 5, PHP rotation of the image 1:2: Before rotation 3:4: 5:6: Header ("...

  • Related Article

    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.