使用php将html文本转换为图像
使用 php 将嵌入 html 标签中的文本转换为图像并保持 html 标签中写入的样式的最佳方法是什么?例如:
转变 :
<span class="Apple-style-span" style="font-size: xx-large;"><font class="Apple-style-span" color="#F4A460">Stack </font><font class="Apple-style-span" color="#800000">Overflow</font></span>
into : 有相关课程吗?或者我应该将其分解并一一阅读标签?有什么建议吗?
what's the best way to convert a text embedded in a html tag to an image using php keeping the style written in the html tag ? for example :
convert :
<span class="Apple-style-span" style="font-size: xx-large;"><font class="Apple-style-span" color="#F4A460">Stack </font><font class="Apple-style-span" color="#800000">Overflow</font></span>
into :
is there any class for it ? or should I explode it and read the tags one by one ? any suggestion ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能想看看 Painty。尽管它并不完全是您正在寻找的东西,因为您必须为其提供一系列选项,但它应该是您可以扩展的良好资源。
不确定您是否还想渲染 HTML 代码段中使用的字体,但如果您这样做,您还必须获取所有常用的 Web 字体并将它们全部放在脚本可以访问的文件夹中读。
希望这有帮助。
Might want to have a look at Painty. Although it isn't exactly what you're looking for because you'll have to feed it an array of options, it should be a good resource on which you can expand.
Not sure if you also want to render the font(s) being used in your HTML snippet, but if you do, you would also have to get all the commonly used web-fonts and put them all in a folder from where the script can read.
Hope this helps.
有了 PHP GD 库支持,是的:
http:// visionmasterdesigns.com/tutorial-convert-text-into-transparent-png-image-using-php/(包括字体/大小技术)
http://corpocrat.com/2009/06/23/php-script-to-convert-textemail-address -到图像/
With PHP GD Library support, yes:
http://visionmasterdesigns.com/tutorial-convert-text-into-transparent-png-image-using-php/ (font/size technique included)
http://corpocrat.com/2009/06/23/php-script-to-convert-textemail-address-to-image/
看看这个
http://code.google.com/p/wkhtmltopdf/downloads/list
该项目以使用 webkit 引擎将 html 转为 pdf 为中心,但也有 html 转图像的二进制文件和源代码。不过,它是一个外部二进制文件,因此在您的用例中可能对您没有用处。
否则我会研究一下 imagemagick。
Check this one out
http://code.google.com/p/wkhtmltopdf/downloads/list
The project is centered around html to pdf using the webkit engine, but there are also binaries and source for html to image. It's an external binary though, so might not be useful to you in your use-case.
Otherwise I would look into imagemagick.