开发者

converting html text to an image with php

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 :

converting html text to an image with php

is there any class for it ? or should I explode it开发者_如何学JAVA and read the tags one by one ? any suggestion ?


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.


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/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜