LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PHP html to image (https://www.linuxquestions.org/questions/programming-9/php-html-to-image-4175421464/)

conflicker 08-10-2012 03:15 PM

PHP html to image
 
Hi, I've been looking a script or library that allow me to convert html to image, I came up with the GD image but not yet sure and also with wkhtmltoimage that can be installed in the server to make it work.

I just want to get an idea for a better way of converting html to image.

Thank you for your ideas.

theNbomr 08-10-2012 04:11 PM

HTML describes how a web browser should render a page. Whatever you come up with is going to have to have all of the functionality of a web browser, as well as the ability to render to an image file. You might be able to use GD as the final rendering engine, but there will be a lot of processing of data in between, such as rendering fonts, fetching inline images, handling javascript, possibly Java Applets, interpreting CSS, and probably other stuff I haven't though of.
It will probably be easier to craft some kind of script that launches an existing browser, and uses X-based tools to capture the browser window content to an image file. That, too, will have problems, unless you only capture pages that can be rendered within the dimensions of your X server. Perhaps a virtual X server, such as Xvfb can help with that.
A few standard applications that could get the process started: xwininfo, xlsclients, xwd, the ImageMagik collection, and the aforementioned Xvfb.

--- rod.

dugan 08-10-2012 04:22 PM

You might consider using PhantomJS.

http://code.google.com/p/phantomjs/wiki/QuickStart

Scroll down to "rendering"


All times are GMT -5. The time now is 02:59 PM.