【问题标题】:Create an image from data details in site从站点中的数据详细信息创建图像
【发布时间】:2020-03-21 13:42:21
【问题描述】:

我想问一下如何根据我网站上的更新数据创建图像? 比如像这样的图片:

[![x][1]][1]

图片的详细信息来自这个网址:[Pine][2]。

这是完整的代码:

它会根据该链接显示带有更新数据的图像。

有人可以告诉我我必须在 google 中找到什么以获得这样的详细信息吗?这段代码是什么类型的?

【问题讨论】:

    标签: php html image fetch


    【解决方案1】:

    你应该使用 GD 库或 Imagick(ImageMagick)

    使用GD创建图像的示例

    安装或启用已经安装的GD扩展(https://stackoverflow.com/a/44720393/8579824

    <?php
    // Set the content-type
    header('Content-type: image/png');
    
    // Create the image
    $im = imagecreatetruecolor(400, 30);
    
    // 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, 399, 29, $white);
    
    // The text to draw
    $text = 'Testing...';
    // Replace path by your own font path
    $font = 'arial.ttf';
    
    // Add some shadow to the text
    imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
    
    // Add the text
    imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
    
    // Using imagepng() results in clearer text compared with imagejpeg()
    imagepng($im);
    imagedestroy($im);
    ?> 
    
    

    【讨论】:

    • 只显示白色背景的空白图像? “正在测试...”文本在哪里?
    猜你喜欢
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 1970-01-01
    • 2014-09-15
    • 2017-09-16
    • 2010-12-06
    相关资源
    最近更新 更多