php imagecreatetruecolor创建高清图片函数
php imagecreatetruecolor创建高清图片函数
imagecreatetruecolor()返回一个图像标识符代表指定大小的黑色形象。
根据你的PHP和GD版本中函数定义与否。对于PHP 4.0.6通过4.1.x这个函数总是存在的
,如果广东模块加载,但它要求GD2的情况下被安装了PHP将发出一个致命错误并退出。
用PHP 4.2.x版这种行为是不同的人发出警告,而不是一个错误。其他版本只定义此功
能,
看看实例
<?php header ('Content-type: image/png'); $im = @imagecreatetruecolor(120, 20) or die('Cannot Initialize new GD image stream'); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); imagepng($im); imagedestroy($im); ?>
我提出这方面合作 - 结合一些例子,然后动态生成的文本。但是,与此设置,我能得
到透明背景的工作也。
<?php // Set the content-type header('Content-type: image/png'); // Create the image $im = imagecreatetruecolor(175, 15); imagesavealpha($im, true); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 25, $black); $trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127); imagefill($im, 0, 0, $trans_colour); // The text to draw $text = $_GET['text']; // Replace path by your own font path $font = 'catriel regular.ttf'; // Add some shadow to the text imagettftext($im, 9, 0, 13, 16, $black, $font, $text); // Add the text imagettftext($im, 9, 0, 12, 15, $white, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?>
本文地址:http://www.phprm.com/function/php-imagecreatetruecolor.html
转载随意,但请附上文章地址:-)