-1

Possible Duplicate:
How to save webpage as a image file using PHP?

I would like to create an image on the server using a url string that is given. I want a screen shot of a website to be created. Is it possible with PHP GD , if so how ? Thanks

Community
  • 1
  • 1
Alon
  • 3,734
  • 10
  • 45
  • 64

3 Answers3

1

You need something like PhantomJS to do it. This can be called from PHP.

Community
  • 1
  • 1
Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
0

Pretty sure GD can't handle this by itself. You'd need an HTML renderer too.

wizzardmr42
  • 1,634
  • 12
  • 22
  • Is there a way to use the string I have in file_get_contents('http://someurl.com') and create from it an image or a pdf ? – Alon Oct 24 '12 at 08:45
  • You can use some existing scripts or libs to generate a PDF from an pure HTML/CSS-Site. The only one I know that produces acceptable results is this: http://www.princexml.com/ – Ron Oct 24 '12 at 08:51
  • I think you'd need a paid component to do that or at least run it through a browser on the server side and screenshot it (doubt that is easy to get working reliably though!). You are going to hit problems if you just grab the string though as it won't be able to resolve references to relative URLs for things like CSS etc. – wizzardmr42 Oct 24 '12 at 08:52
0

As far as I know, there is no existing PHP-Lib, which can do this. PHP-GD has to do with graphics, but you cant do this with it. Even if: What will happen, if the Site uses Javascript to enable certain important parts of a site? Or even images or other resources, that require long running requests? Or consider sites using flash... There are some tools for linux to take screenshots in batch - configurable with timer etc.

Ron
  • 1,336
  • 12
  • 20