[CentOS] convert webpage to image

Wed Aug 14 14:38:33 UTC 2013
Marko Vojinovic <vvmarko at gmail.com>

On Wed, 14 Aug 2013 07:20:03 -0700 (PDT)
Joseph Spenner <joseph85750 at yahoo.com> wrote:
> >From: Carl T. Miller <carl at carltm.com>
> >To: CentOS <centos at centos.org> 
> >Sent: Wednesday, August 14, 2013 5:47 AM
> >Subject: [CentOS] convert webpage to image
> >
> >What is the easiest way to convert a webpage into a jpg
> >or png file?  I've seen several programs that can do
> >various conversions, but nothing open source that can
> >do it in a single conversion.
> 
> I wrote a few lines to do this, but it involves using firefox, and
> 'import' from ImageMagick.
> 
> The first script starts firefox in a virtual frame:
> 
> ===
> Xvfb :2 -screen 0 1280x1024x24 > /dev/null 2>&1 &
> export DISPLAY=localhost:2.0
> 
> firefox http://ip.of.your.page/page.html &
> ===
> 
> Then the second script captures/crops what I want:
> 
> ===
> export DISPLAY=localhost:2.0
> import -crop '1024x512+54+235' -window root /path/to/result.png
> ==
> 
> You'll have to adjust the crop values to what you want.

But what if the size of the website is larger than the screen size? I
assume the OP wants to "see" the whole website in a single picture, and
the website might span more than a single visible screen (and require
scrolling to see the whole thing).

All screenshot-related methods would then need to take multiple
pictures, scroll the website in the browser a "windowfull" at a time in
all directions, and afterwards calculate how to concatenate all those
pictures into a big one. While this can be done in principle, I think
that any implementation would get Real Ugly Real Soon(tm).

A more reasonable approach would be to have the browser itself dump the
image of the site --- the browser is the one actually rendering the
thing from html in the first place. Any browser plugins around for this?

Best, :-)
Marko