php 画图片

<?php
    
    // 使用php操做gd库作图
    // 1. 建立一个画布资源
    $im = imagecreatetruecolor(80, 40);

    // 2. 画内容
    // 2.1 先位画布准备颜色
    $string_color = imagecolorallocate($im, 255, 255, 255);
    // 2.2 往画布上写入字符串
    imagestring($im, 5, 15, 14, 'hello', $string_color);

    // 3. 设置响应头
    header('Content-type:image/png');

    // 4. 输出图片
    //imagepng($im);
    imagepng($im, 'test.png');

    // 5. 释放资源
    imagedestroy($im);

?php>
相关文章
相关标签/搜索