0

Like what browsershots.org did they can have a screenshot of the url i have inputted are there any available script like that?

spicykimchi
  • 1,151
  • 5
  • 22
  • 41

1 Answers1

3

It's pretty easy to do with wkhtmltopdf and its wkhtmltoimage variant:

exec("./wkhtmltoimage http://example.org/ image.png");

Note that the output filename must be in a writable location.

mario
  • 144,265
  • 20
  • 237
  • 291
  • @mario how to use it?DO i have to install the wkhtmltoimage to my server? – spicykimchi Apr 14 '11 at 03:38
  • 1
    @khem: Try reading the [manual](http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html). – drudge Apr 14 '11 at 03:39
  • @khem: Yes, someone has to install it. Click the link, download, extract the tool. It's no effort really. – mario Apr 14 '11 at 03:42
  • @khem: In any local directory. It's not a Windows app, btw. You will have to find something more fiddly for that: http://stackoverflow.com/questions/757675/website-screenshots-using-php – mario Apr 14 '11 at 03:46
  • @mario I will put it on my file server..I don't have any experience in installing app on file server except PHP scripts.This is my directory ... cgi-bin logs Maildir public_html streaming .bach_history .bash_logout Where to put it? the location of my script is here /public_html/gpslocnfo – spicykimchi Apr 14 '11 at 03:55
  • @khem: Same directory as the php script from which you want to use it. – mario Apr 14 '11 at 03:57
  • @mario the filename is wkhtmltoimage-amd64 – spicykimchi Apr 14 '11 at 03:58
  • Or just install it anywhere and use an absolute path if you are that unsure how and where PHP executes. – mario Apr 14 '11 at 03:59
  • in rendering the outputis it right to do it this way? "; ?> – spicykimchi Apr 14 '11 at 04:02
  • no output...in my directory there are no image.png that exist. – spicykimchi Apr 14 '11 at 04:08
  • It must be a writable location. Try out `exec("./wkhtmltoimage 'http://google.com/' /tmp/test.png");`. If that gives no result in /tmp, you need to adapt the path `./` to the tool still. – mario Apr 14 '11 at 04:11
  • @mario thanks it works...now got a problem with setting height and width in the documentation it say --scale-h --scale-w $e = exec("/home/gpsradio/public_html/locnfo/wkhtmltoimage 'http://google.come/' --scale-h200 --scale-w200 /home/gpsradio/public_html/locnfo/image.gif"); it won't work. – spicykimchi Apr 15 '11 at 05:14
  • 1
    @khem: I've never really used the scaling feature, only the crop options. But I think you need a space between the `--scale-h 200` option and number, and also `--scale-w 200`. If that doesn't work or the result looks odd I would advise that you scale it using the GD functions, or imagemagik with `exec("mogrify --resize 200x200 .../image.gif");` – mario Apr 15 '11 at 07:22