Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PHP to generate screenshots from an HTML source

Tags:

php

image

I've got an idea for a site that would generate png or jpeg screenshots of webpages on the fly. The end user would never see the pages, but the HTML would be turned into a screenshot instead and the end user would see that screenshot.

How can I get started on this? I guess what I'm looking for is some kind of PHP function that takes the HTML as an argument and then produces an image file in a specified location.

like image 268
Jim Avatar asked Nov 06 '22 17:11

Jim


2 Answers

As far as I know, PHP does not do this.

You can, however, find a solution using external tools. Here is how I would do it

  1. Generate the HTML
  2. I would pass this HTML to a external tool using exec. There is, for instance this one.
  3. Then, display the generated picture
like image 109
Benoît Vidis Avatar answered Nov 11 '22 06:11

Benoît Vidis


http://www.zubrag.com/articles/create-website-snapshot-thumbnail.php

like image 38
Millions Avatar answered Nov 11 '22 07:11

Millions