简体   繁体   中英

Using PHP to generate screenshots from an HTML source

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM