Tuesday, January 1, 2019

PHP generates a transparent background image instance

This article describes the method of php to generate a transparent background image, a php generated background image example, a reference to friends in need.
Example, php generates the code for the background image.

Copy Code Code Sample:
<?php
//Transparent background image
Header(‘content-type:text/html;charset=gbk’);
$safess = $_get[safe];
$dir = dirname(__file__).”/simsun.ttc”;
$safe=iconv(“gb2312",”utf-8", $safess);
$im=imagecreatetruecolor(160,18);
$color=imagecolorallocate($im,229,231,230);
Imagecolortransparent($im,$color); // Set to transparent color, output the background set above if commenting out the line
Imagefill($im,0,0,$color);
$textcolor=imagecolorallocate($im,0,0,0);
Imagettftext($im,9,0,30,12,$textcolor,$dir,$safe);
//imagestring($im,30 , 5, 3, $safe, $textcolor);
Header(“content-type:image/png”);
Imagegif($im);
?>

No comments:

Post a Comment