homepage Welcome to WebmasterWorld Guest from 54.197.171.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
How can i create screenshot of url?
html to image in linux
peter_k




msg:604878
 2:29 pm on Nov 28, 2004 (gmt 0)

Hi everybody! This site is wonderful!

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.

 

tedster




msg:604879
 11:31 pm on Nov 28, 2004 (gmt 0)

Welcome to the forum, Peter. This topic came up just a few days ago [webmasterworld.com].

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.


peter_k




msg:604880
 9:14 pm on Nov 29, 2004 (gmt 0)

Thanks!

I have one question:

Will mozilla work under linux serwer, where is not graphic interface? Will it create screenshots?

jollymcfats




msg:604881
 2:30 am on Nov 30, 2004 (gmt 0)

At the risk of splitting the screenshot thread, there is an easy way to do this on a server with no graphics hardware: Xvfb. From the manpage:

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.

In other words it pretends to be an X server and video card. Xvfb is suprisingly lightweight, memory wise. It doesn't require a full installation of X11 on the server, a window manager or to be run as root.

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.

peter_k




msg:604882
 11:15 am on Dec 5, 2004 (gmt 0)

Thanks for reply! This is what i search for!

leond




msg:604883
 3:22 pm on Jan 2, 2005 (gmt 0)

Hi,

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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved