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
Return to the default flat view Create a new topic Submit Reply
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:
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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: Sat Nov 23 18:09:37 GMT 2024

Total time taken to generate the page: 0.04654 seconds