php利用imagecreatetruecolor动态生成高清图片代码
<?php //实例用我们用imagecreatetruecolor 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); //我把这个一起 - 结合较好的例子,然后动态生成的文本。但是,与此成立,我能得到透明背景以及工作。 //实例二imagecreatetruecolor 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); /* 实例三创建透明图片 如果你想创建一个PNG图像*透明*,其中的背景是完全透明的,所有行动发生在借鉴,除此之外,然后执行下列操作: */ $png = imagecreatetruecolor(800, 600); imagesavealpha($png, true); $trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127); imagefill($png, 0, 0, $trans_colour); $red = imagecolorallocate($png, 255, 0, 0); imagefilledellips教程e($png, 400, 300, 400, 300, $red); header("Content-type: image/png"); imagepng($png); /* 你要做的就是创建一个真正的彩色图像,确保阿尔法保存状态是,然后填写一个颜色,也经历了阿尔法级别设置为完全透明(127)的图像。 从上面的代码产生的巴新将有一个完全透明的背景(一红色圆圈拖到Photoshop中的图像,以了解自己) The resulting PNG from the code above will have a red circle on a fully transparent background (drag the image into Photoshop to see for yourself) */
本文地址:http://www.phprm.com/function/imagecreatetruecolor.html
转载随意,但请附上文章地址:-)