How to save a web page as an image file using PHP?

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

+3
javascript html php
Jul 04 '10 at 16:35
source share
4 answers
+7
Jul 04 '10 at 16:39
source share

You will need to make a page with something. If you really want to use php, I suggest you have HTMLTOPS , which displays the page and outputs it to a ps (ghostscript) file, then convert it to .jpg, .png, .pdf .. maybe a little slower with complex pages (and not supports all CSS).

Otherwise, you can use wkhtmltopdf to display the html page in pdf, jpg, whaterver format. Accept CSS2.0, use webkit (safari wrapper) to display the page .. so that should be fine. You must also install it on your server.

Source: Website Screenshots Using PHP

+2
Jul 04 '10 at 16:39
source share

Like others, it would be difficult to do only in PHP. However, there is an easy-to-use cross-platform CutyCapt tool that does exactly what you need. The best part of this tool is that it is autonomous and independent of anything else.

+2
Jul 04 2018-10-16 at
source share

You cannot do this with pure PHP, try deploying a browser like Mozilla with headless mode and letting it handle a snapshot of the page.

+1
Jul 04 '10 at 16:39
source share



All Articles