web page to image [message #175561] |
Sun, 09 October 2011 00:39 |
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 #175563 is a reply to message #175561] |
Sun, 09 October 2011 02:15 |
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 |
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 |
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 |
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 |
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 |
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 |
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 #175674 is a reply to message #175561] |
Tue, 18 October 2011 00:40 |
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.
|
|
|