图像上的文字 [英] Text on a image

查看:131
本文介绍了图像上的文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在php中的图像上动态放置文本?
然后将其发送到rss Feed?

Is it possible to dynamically place text on an image in php? And then send it to an rss feed?

推荐答案

是的,可以使用 GD 功能或 ImageMagick 功能,取决于您的服务器上安装的功能以及您喜欢的功能。

Yes, can use either the GD functions or the ImageMagick functions, depending on which is installed on your server and which you prefer.

使用GD它会是这样的:

Using GD it would go something like this:

<?php
$img = imagecreatefromjpeg('my.jpg');
$textColor = imagecolorallocate($img, 0, 0, 0); // black text

imagefttext($img, 13, 0, 105, 55, $textColor, './arial.ttf', 'Hello World');

// Output image to the browser
header('Content-Type: image/jpeg');
imagejpeg($img);

// Or save to file
imagejpeg($img, 'my-text.jpg');

imagedestroy($img);
?>

编辑:

放置图片在RSS源中,您可以将其保存到文件中并将URL放入您的Feed中。

To put the image into your RSS feed you would save it to a file and put the URL into your feed.

这篇关于图像上的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆