简体   繁体   中英

How to save webpage as a image file using PHP?

I want to save webpage as image file or i want to take snapshot of an webpage using PHP. Just like firefox extension Fireshot doing.

You'll need to render the page with something. If you really want to only use php, i suggest you HTMLTOPS , wich render the page and output it in a ps file (ghostscript), then, convert it in a .jpg, .png, .pdf.. can be little slower with complex pages (and dont support all the CSS).

Else, you can use wkhtmltopdf to output a html page in pdf, jpg, whaterver.. Accept CSS2.0, use the webkit (safari's wrapper) to render the page.. so should be fine. You have to install it on your server, as well..

Source: Website screenshots using PHP

Like others have said, it would be difficult to do in PHP alone. However, there is an easy-to-use cross-platform tool called CutyCapt that does exactly what you need. The best part about this tool is that it's stand-alone and doesn't depend on anything else.

你不能用纯PHP做到这一点,尝试用无头模式分配像Mozilla这样的浏览器,让它处理页面的快照。

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