is there a way (hopefully through the GD library, but other ones are fine) to create an img from pure html (using php)? I need to fetch external sites and show icons. Im assuming an image method would save load time, but if not I could simply load in the html from the page into a div, as long as the inner html, head, and body tags dont cause problems
3
-
You're saying you want to render the HTML/CSS into an image?Oliver Charlesworth– Oliver Charlesworth2011-11-10 00:28:08 +00:00Commented Nov 10, 2011 at 0:28
-
what about a screenshot instead?user866503– user8665032011-11-10 00:35:55 +00:00Commented Nov 10, 2011 at 0:35
-
1check this out: stackoverflow.com/questions/721549/…user866503– user8665032011-11-10 00:38:28 +00:00Commented Nov 10, 2011 at 0:38
Add a comment
|
1 Answer
Rendering a complete Html page with PHP alone is not possible. Rendering an Html includes applying CSS load images and editing the whole thing with javascript and doing this with pure php would take ......well forever. Your best shot would be using a cmd tool to render the page and output an image. You can use shell commands in PHP.
Shell commands from PHP code: http://php.net/manual/en/function.shell-exec.php
Creating a screenshot: Command line program to create website screenshots (on Linux)