【发布时间】:2020-03-21 13:42:21
【问题描述】:
我想问一下如何根据我网站上的更新数据创建图像? 比如像这样的图片:
[![x][1]][1]
图片的详细信息来自这个网址:[Pine][2]。
这是完整的代码:
它会根据该链接显示带有更新数据的图像。
有人可以告诉我我必须在 google 中找到什么以获得这样的详细信息吗?这段代码是什么类型的?
【问题讨论】:
我想问一下如何根据我网站上的更新数据创建图像? 比如像这样的图片:
[![x][1]][1]
图片的详细信息来自这个网址:[Pine][2]。
这是完整的代码:
它会根据该链接显示带有更新数据的图像。
有人可以告诉我我必须在 google 中找到什么以获得这样的详细信息吗?这段代码是什么类型的?
【问题讨论】:
使用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);
?>
【讨论】: