php - 从站点中的数据详细信息创建图像
问题描述
我想问一下如何根据我网站上的更新数据创建图像?例如像这样的图像:
[![x][1]][1]
图片的详细信息来自以下网址:[Pine][2]。
这是完整的代码:
它根据该链接显示带有更新数据的图像。
有人可以告诉我我必须在谷歌中找到什么以获得这样的细节吗?这个代码是什么类型的?
解决方案
您应该使用 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);
?>
推荐阅读
- jasper-reports - Jasper Reports:将来自不同数据适配器的两个数据集连接在一起的最佳方法是什么?
- javascript - arr.push(arr.splice(n,1)) “吞噬”移动对象的属性
- sql - 使用 SQL 查询获取 ID 的 R 向量错误
- android - 数据库查询在 SQLite 房间中不起作用
- c# - 如何删除我的 DataGridView 列中的时间
- c# - Jquery Select2,从结果控制器设置参数函数以获取 ID 或点击 Jquery Select2
- regex - 使用正则表达式python在标点符号后小写字母
- python-3.x - 如何通过python中的用户输入找出阶乘数?
- node.js - Hyperledger Fabric installChaincode 错误在安装链码请求中缺少对等对象
- c - 64 位数字和 (C) [随意编辑我的英语]