Sina Fathieh
Sina Fathieh

Reputation: 1725

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 : alt text

is there any class for it ? or should I explode it and read the tags one by one ? any suggestion ?

Upvotes: 5

Views: 6354

Answers (3)

Valentin Flachsel
Valentin Flachsel

Reputation: 10825

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.

Upvotes: 2

pharalia
pharalia

Reputation: 709

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.

Upvotes: 0

Related Questions