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

Source: Internet
Author: User
Tags 0xc0

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

1, using the PHP GD library function to draw 3D fan chart

   1:  <?php
   2:  header ("Content-type","Text/html;charset=utf-8");
   3:/* Sector chart * /
   4:  $image = Imagecreatetruecolor (+);    / * Create canvas *  /
   5:
   6:/* Set the color required for the canvas * /
   7:  $white = imagecolorallocate ($image, 0xff,0xff,0xff);
   8:  $gray = imagecolorallocate ($image, 0xc0, 0xc0, 0xc0);
   9:  $darkgray = imagecolorallocate ($image, 0x90, 0x90, 0x90);
  Ten:  $navy = imagecolorallocate ($image, 0x00, 0x00, 0x80);
One   :  $darknavy = imagecolorallocate ($image, 0x00, 0x00, 0x50);
  :  $red = imagecolorallocate ($image, 0xFF, 0x00, 0x00);
  :  $darkred = imagecolorallocate ($image, 0x90, 0x00, 0x00);
  14:
*   /* Fill Background color * /
  :  imagefill ($image, 0, 0, $white);
  17:
  :/*3d production * /
  :for($i = $, $i > $i-)
  :  {
  :     Imagefilledarc ($image, $i, -160, $darknavy, img_arc_pie);
A   :     Imagefilledarc ($image, $i, $darkgray, Img_arc_pie , and,);
Max   :     Imagefilledarc ($image, $i, $darkred, Img_arc_pie) , Max.
  :  }
*   /* Draw Elliptical arc and fill * /
  :  imagefilledarc ($image, -160, Max, $darknavy, Img_arc_pie);
  : imagefilledarc ($image,-------------------- $darkgray, img_arc_pie);
  : imagefilledarc ($image,---------------------- $darkred, img_arc_pie);
  29:
  :/* Draw a String * /
  :"30%", $white);
  :"60%", $white);
  :"10%", $white);
  34:
*   /* Output image * /
  £ º  header ("Content-type:image/png");
  Panax Notoginseng:  imagepng ($image);
  38:
  :/* Release resources * /
Max   :  Imagedestroy ($image);
In   :  ?>

Effect:

2. Zooming the picture

   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 Zoom
  :* @param string $filename   The URL of the picture
One   :* @param int    $width      Set the maximum width of the picture zoom
  * @param int    $height     Set the maximum height of picture zoom
  * /
  :function thumb ($filename, $width =130, $height =130)
  :  {
*   /     * Get the size of the original image * /
  :     list($width _orig, $height _orig) = getimagesize ($filename);
  18:
       */* According to the parameters $width and $height, the proportional height and width are converted .
  :     if($width && ($width _orig < $height _orig))
  :     {
  :         $width = ($height/$height _orig) * $width _orig;
  :     }
  :     Else
  :     {
  :         $height = ($width/$width _orig) * $height _orig;
  :     }
  28:
*   /     * Create a canvas with a new size * /
  :     $image _p = Imagecreatetruecolor ($width, $height);
  31:
*   /     * Get Image resources * /
  :     $image = imagecreatefrompng ($filename);
  34:
*   /     * Use imagecopyresampled zoom * /
       imagecopyresampled ($image _p, $image, 0, 0, 0, 0, $width, $height, $width _orig, $height _orig); 
  37:
       */* Save scaled Picture and name */
  :     imagepng ($image _p,' test.png ');
  40:
All   :/     * FREE resources * /
  :     Imagedestroy ($image _p);
  :     Imagedestroy ($image);
  :  }
*   /* Call function * /
  :  thumb (' 1.png ');
?>   :
  :  <div>
  $     
  :     <img src="test.png" style= "border:1px solid red;" >
  Wuyi:  </div>

Effect:


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

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.