Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 822
Sina Fathieh Avatar asked Nov 06 '22 05:11

Sina Fathieh


1 Answers

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.

like image 56
Valentin Flachsel Avatar answered Nov 12 '22 10:11

Valentin Flachsel