Home > Backend Development > PHP Tutorial > Example of generating transparent background image in php

Example of generating transparent background image in php

WBOY
Release: 2016-07-25 08:53:46
Original
2213 people have browsed it
  1. //Transparent background image
  2. header('content-type:text/html;charset=gbk');
  3. $safess = $_get[safe];
  4. $dir = dirname(__file__ ).”/simsun.ttc”;
  5. $safe=iconv(“gb2312″,”utf-8″,$safess);
  6. $im=imagecreatetruecolor(160,18);
  7. $color=imagecolorallocate($im,229,231,230 );
  8. imagecolortransparent($im,$color); // Set to transparent color. If you comment out this line, the background set above will be output.
  9. imagefill($im,0,0,$color);
  10. $textcolor=imagecolorallocate( $im,0,0,0);
  11. imagettftext($im,9,0,30,12,$textcolor,$dir,$safe);
  12. //imagestring($im,30, 5, 3, $safe , $textcolor);
  13. header("content-type:image/png");
  14. imagegif($im);
  15. ?>
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template