Andrew Libby on 22 Nov 2015 09:10:46 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Need to Convert HTML Page to jpg Image


Hi Casey/ Jon,

You can use xvfb/ selenium to do this.   It might be overkill,
but we've done it.

http://linuxboxadmin.com/micro-howtos/userland/screenshots-through-xvfb.html


Short story is we need to pull data from a site regularly, but
they don't porovide an API.  Years back we used mechanize to
login, generate the desired report and download it.  Then they started
doing all this ajaxy stuff that requires javascript in the
user agent.

We would up using selenium running firefox with xvfb.  It's hideous, but
it works.  From time to time when we have problems we use xwd to
capture what's on the screen of a hanging xvfb process.

If having the browser window included your output is acceptable,
this should work.  If not, you'll probably need to do further
work to automatically crop the image.

Lastly, if the HTML renders taller than the browser window, you'll
be missing what's not "on screen" at the time of the screen grab.

Andy


On 11/22/15 12:00 PM, Jonathan Simpson wrote:
> I'm interested in this as well
> 
> On Nov 22, 2015 11:58 AM, "Casey Bralla" <MailList@nerdworld.org
> <mailto:MailList@nerdworld.org>> wrote:
> 
>     I'm writing a web application where users will upload an HTML page
>     which will
>     be shown on another page.   I want to allow the user to see a
>     miniature image
>     of the HTML file they uploaded.
> 
>     Anybody know how to convert an HTML page into a jpg or png file? 
>     I've seen
>     online tools to do this, but I need to have my application automatically
>     convert them on the fly (ie: I need a cli program to convert HTML
>     into a png or
>     jpg.)
> 
> 
>     TIA!
>     --
> 
>     Casey Bralla
> 
>     Chief Nerd in Residence
>     The NerdWorld Organisation
>     www.NerdWorld.org <http://www.NerdWorld.org>
>     ___________________________________________________________________________
>     Philadelphia Linux Users Group         --       
>     http://www.phillylinux.org
>     Announcements -
>     http://lists.phillylinux.org/mailman/listinfo/plug-announce
>     General Discussion  -- 
>      http://lists.phillylinux.org/mailman/listinfo/plug
> 
> 
> 
> ___________________________________________________________________________
> Philadelphia Linux Users Group         --        http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
> 

-- 
Andrew Libby
alibby@xforty.com
484-887-7505 x 1115
http://xforty.com
http://www.kineticweb.com/
http://zugunroute.com
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug