Forum Moderators: open
I've a web catalogue of links and i want to add function, that will create screens of this links (something like www.searchsight.com).
In what way can i easily create mini screenshots of this websites on linux server (using command line)?
Thanks for any replies.
As I mentioned in that thread, you can check out this thread in our Perl/CGI forum for ideas:
Script to generate thumbnail [webmasterworld.com]
#4
mattx17:One way you can do it is you have a browser such as mozilla installed on the server, and you also have X running (and a window manager), you can get a screenshot this way:
Leave the browser window open, fully maximized, in your server's X session. Run the command (from your script):
mozilla -remote openURL('http://www.mysite.com')
This should open the URL up in the servers X session. Once that is done, take a screen shot with any of the available tools for X. We'll use xwd as an example:
xwd -frame -root -out myscreenshot.xwd
This will take a full screenshot of the X root window, which should have the browser window open at that URL.
After that, you may have to use ImageMagick or NetPBM to convert the file into something usable for the web.
Hope this helps, even if it just points you in the right direction.
Xvfb is an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory.
Here's how one might use it for screenshots.
Screenshot "server" script:XAUTHORITY=
Xvfb :2 -screen 0 800x600x32 -fbdir /tmp &
DISPLAY=:2.0 mozilla -width 800 -height 600 &
Screenshooter script:XAUTHORITY=
DISPLAY=:2.0 mozilla -remote "openURL(http://example.com)"
sleep 5 # give the page time to load
cp /tmp/Xvfb_screen0 /tmp/screenshot.xwd
Like mattx17, I'll leave converting a .xwd format image into something more useful as an exercise for the googler. Xvfb is an optional package in most Linux distributions, usually with names like xorg-x11-Xvfb or XFree86-Xvfb.
I followed the Xvfb method (excellent idea!), using a 24-bit buffer and xwdtopnm ¦ pnmtojpeg/png/tif.
It all worked OK until I saw the final picture - it looks painfully deinterlaced and, well, wrong. I don't know much X as most of my experience is with headless servers - where should I start troubleshooting?
Thanks for your help!
[edited by: tedster at 6:07 pm (utc) on Jan. 2, 2005]