FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » web page to image
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
web page to image [message #175561] Sun, 09 October 2011 00:39 Go to next message
bob is currently offline  bob
Messages: 11
Registered: February 2011
Karma: 0
Junior Member
I want to turn a web page into a 768x1024 image using PHP. For
instance the script might load http://www.example.com/ and output a
768x1024 image. Anyone know how to do this?
Re: web page to image [message #175562 is a reply to message #175561] Sun, 09 October 2011 01:35 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
bob wrote:
> I want to turn a web page into a 768x1024 image using PHP. For
> instance the script might load http://www.example.com/ and output a
> 768x1024 image. Anyone know how to do this?
>
Forget it: you need a browser to do that.
Re: web page to image [message #175563 is a reply to message #175561] Sun, 09 October 2011 02:15 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/8/2011 8:39 PM, bob wrote:
> I want to turn a web page into a 768x1024 image using PHP. For
> instance the script might load http://www.example.com/ and output a
> 768x1024 image. Anyone know how to do this?
>

First you need something to render the page, similar to a browser. PHP
can't do that (at least not without a few man-decades of work). Then
you need to capture that page, which again, PHP can't do.

Once you've gotten this far, you could use the gd functions to create an
image.

The real question here is - what problem are you trying to solve?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: web page to image [message #175564 is a reply to message #175561] Sun, 09 October 2011 05:18 Go to previous messageGo to next message
Michael Vilain is currently offline  Michael Vilain
Messages: 88
Registered: September 2010
Karma: 0
Member
In article
<74de1a18-820b-4985-899d-737b2fb8b655(at)u6g2000vbo(dot)googlegroups(dot)com>,
bob <bob(at)coolgroups(dot)com> wrote:

> I want to turn a web page into a 768x1024 image using PHP. For
> instance the script might load http://www.example.com/ and output a
> 768x1024 image. Anyone know how to do this?

You'd have to 'build an image' of the site using the internal equivalent
of a web browser. And they all render HTML slightly differently. Not
an easy task to do in PHP.

Or you could just tell Safari to PRINT TO PDF and save the web site as a
PDF file. That's what I do. Better than an image because I can click
on the links and be taken to the sites referenced.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
Re: web page to image [message #175566 is a reply to message #175562] Sun, 09 October 2011 06:55 Go to previous messageGo to next message
paris2venice is currently offline  paris2venice
Messages: 9
Registered: October 2011
Karma: 0
Junior Member
On Oct 8, 6:35 pm, The Natural Philosopher <t...@invalid.invalid>
wrote:
> bob wrote:
>> I want to turn a web page into a 768x1024 image using PHP.  For
>> instance the script might loadhttp://www.example.com/and output a
>> 768x1024 image.  Anyone know how to do this?
>
> Forget it: you need a browser to do that.

It could be done if you can execute external Unix commands with PHP
which I believe you can. I'm just not advanced enough at PHP to show
how Unix commands can be executed to accomplish this.
Re: web page to image [message #175567 is a reply to message #175566] Sun, 09 October 2011 08:11 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
paris2venice wrote:
> On Oct 8, 6:35 pm, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>> bob wrote:
>>> I want to turn a web page into a 768x1024 image using PHP. For
>>> instance the script might loadhttp://www.example.com/and output a
>>> 768x1024 image. Anyone know how to do this?
>> Forget it: you need a browser to do that.
>
> It could be done if you can execute external Unix commands with PHP
> which I believe you can. I'm just not advanced enough at PHP to show
> how Unix commands can be executed to accomplish this.

system() is the way, or the exec() type calls. BUT essenially you want
to exec a full screen browser and take a screen shot.


OR bite the bullet and start hacking e.g. Mozilla source.
Re: web page to image [message #175568 is a reply to message #175567] Sun, 09 October 2011 09:18 Go to previous messageGo to next message
houghi is currently offline  houghi
Messages: 45
Registered: September 2011
Karma: 0
Member
The Natural Philosopher wrote:
> paris2venice wrote:
>> On Oct 8, 6:35 pm, The Natural Philosopher <t...@invalid.invalid>
>> wrote:
>>> bob wrote:
>>>> I want to turn a web page into a 768x1024 image using PHP. For
>>>> instance the script might loadhttp://www.example.com/and output a
>>>> 768x1024 image. Anyone know how to do this?
>>> Forget it: you need a browser to do that.
>>
>> It could be done if you can execute external Unix commands with PHP
>> which I believe you can. I'm just not advanced enough at PHP to show
>> how Unix commands can be executed to accomplish this.
>
> system() is the way, or the exec() type calls. BUT essenially you want
> to exec a full screen browser and take a screen shot.
>
>
> OR bite the bullet and start hacking e.g. Mozilla source.

Or perhaps use something like http://browsershots.org/
It all depends on wether you want to do occisional screenshots or want
to download all of the internet.

With the above URL I am sure that you should be able to script it. Not
sure if it is an option or not.


houghi
--
________________________ Open your eyes, open your mind
| proud like a god don't pretend to be blind
| trapped in yourself, break out instead
http://openSUSE.org | beat the machine that works in your head
Re: web page to image [message #175574 is a reply to message #175561] Sun, 09 October 2011 19:39 Go to previous messageGo to next message
bobmct is currently offline  bobmct
Messages: 16
Registered: September 2010
Karma: 0
Junior Member
On Sat, 8 Oct 2011 17:39:53 -0700 (PDT), bob <bob(at)coolgroups(dot)com>
wrote:

> I want to turn a web page into a 768x1024 image using PHP. For
> instance the script might load http://www.example.com/ and output a
> 768x1024 image. Anyone know how to do this?

I do this at work regularly for training/demonstration purposes. I
use a gnome screen capture program which allows me to capture the
entire desktop, current window or even a marked area and save the
capture in any image format I desired. Then these captured images can
be printed, emailed, included, even put in a presentation. Captured
imaged looks as good as the real thing.
Re: web page to image [message #175575 is a reply to message #175574] Sun, 09 October 2011 19:43 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
bobm3(at)worthless(dot)info wrote:
> On Sat, 8 Oct 2011 17:39:53 -0700 (PDT), bob <bob(at)coolgroups(dot)com>
> wrote:
>
>> I want to turn a web page into a 768x1024 image using PHP. For
>> instance the script might load http://www.example.com/ and output a
>> 768x1024 image. Anyone know how to do this?
>
> I do this at work regularly for training/demonstration purposes. I
> use a gnome screen capture program which allows me to capture the
> entire desktop, current window or even a marked area and save the
> capture in any image format I desired. Then these captured images can
> be printed, emailed, included, even put in a presentation. Captured
> imaged looks as good as the real thing.

yeah but that's a manual process innit?

not under software control...
Re: web page to image [message #175582 is a reply to message #175575] Mon, 10 October 2011 07:19 Go to previous messageGo to next message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
The Natural Philosopher, 2011-10-09 21:43:

> bobm3(at)worthless(dot)info wrote:
>> On Sat, 8 Oct 2011 17:39:53 -0700 (PDT), bob <bob(at)coolgroups(dot)com>
>> wrote:
>>
>>> I want to turn a web page into a 768x1024 image using PHP. For
>>> instance the script might load http://www.example.com/ and output a
>>> 768x1024 image. Anyone know how to do this?
>>
>> I do this at work regularly for training/demonstration purposes. I
>> use a gnome screen capture program which allows me to capture the
>> entire desktop, current window or even a marked area and save the
>> capture in any image format I desired. Then these captured images can
>> be printed, emailed, included, even put in a presentation. Captured
>> imaged looks as good as the real thing.
>
> yeah but that's a manual process innit?
>
> not under software control...

gnome-screenshot can also be used as a command line tool with parameters
to do screenshots without user interaction.

See
< http://linux.dsplabs.com.au/gnome-screenshot-screen-capture-under-linux-p22 />
for examples.


--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Re: web page to image [message #175584 is a reply to message #175561] Mon, 10 October 2011 09:12 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 09/10/2011 2:39, bob escribió/wrote:
> I want to turn a web page into a 768x1024 image using PHP. For
> instance the script might load http://www.example.com/ and output a
> 768x1024 image. Anyone know how to do this?

I don't think you'll find a pure PHP rendering engine but, if installing
new software is an option, you can try wkhtmltopdf to convert to PDF and
then ImageMagick to convert the first page to picture:

http://code.google.com/p/wkhtmltopdf/
http://www.imagemagick.org/script/index.php


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: web page to image [message #175674 is a reply to message #175561] Tue, 18 October 2011 00:40 Go to previous message
gordonb.cydcw is currently offline  gordonb.cydcw
Messages: 1
Registered: October 2011
Karma: 0
Junior Member
> I want to turn a web page into a 768x1024 image using PHP. For

Is there a reason for this, besides, of course, Copyright Infringement?

> instance the script might load http://www.example.com/ and output a
> 768x1024 image. Anyone know how to do this?

You need something that will render HTML. There are some packages
that are essentially intended to *PRINT* HTML, but can be used to
get the page rendered into some other format.

One way to do it (manually) is to use the Firefox "print to file"
to print to a .pdf file, then use pdftoppm and one other program
from the NetPBM package to convert it to your favorite form of image
(.png (use pnmtopng), .jpeg (use pnmtojpeg), or whatever). Or you
could save to PostScript and use GhostScript to convert it to your
favorite image format.

Another way to do it (manually or from a script) is to use html2ps
to render the page in Postscript, then use GhostScript to convert
it to your favorite format (GhostScript has a variety of "devices"
which amount to outputting an image of various types into a file).
This can be invoked from PHP running a series of shell commands or
a shell script. Be careful of where you create temporary files or
you'll run into permission problems, as PHP usually runs under an
id without many privileges. Also don't use fixed temporary file
names as several users may be requesting this at the same time,
and they'll clobber each other.

You may need to come up with a way of specifying a "paper size"
that matches what you want in an image, as the first step thinks
it's formatting stuff for a printer.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Editing a combobox
Next Topic: Re: Mass Twitter Account Creator (PHP)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 03 13:28:05 GMT 2024

Total time taken to generate the page: 0.02538 seconds