首页 > 解决方案 > 从站点中的数据详细信息创建图像

问题描述

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

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

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

这是完整的代码:

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

有人可以告诉我我必须在谷歌中找到什么以获得这样的细节吗?这个代码是什么类型的?

标签: phphtmlimagefetch

解决方案


您应该使用 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);
?> 


推荐阅读