php简单创建图片实例

php创建图片教程,我们在编程时经常会看到用php写图片,验证码等,下面是一个简单的php创建图片实例代码:

  1. <?php
  2. $height = 300;
  3. $width = 300;
  4. $im = ImageCreateTrueColor($width, $height);
  5. $white = ImageColorAllocate ($im, 255, 255, 255);
  6. $blue = ImageColorAllocate ($im, 0, 0, 64);
  7. ImageFill($im, 0, 0, $blue);
  8. //ImageLine($im, 0, 0, $width, $height, $white);
  9. ImageString($im, 10, 100, 120, 'Hello,PHP', $white);
  10. Header ('Content-type: image/png');
  11. ImagePng($im);
  12. //开源代码phpfensi.com
  13. ImageDestroy($im);
  14. ?>