How to create a snapshot of a URL in PHP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BG Mahesh

    #1

    How to create a snapshot of a URL in PHP?


    Hi

    Given a URL I want the snapshot of that page as an image. Something
    like


    How do I achieve this in PHP?

    -- Mahesh

  • Miguel Cruz

    #2
    Re: How to create a snapshot of a URL in PHP?

    "BG Mahesh" <mahesh@mahesh. comwrote:
    Given a URL I want the snapshot of that page as an image. Something
    like

    ttp://google.com
    >
    How do I achieve this in PHP?
    You can't, at least not with PHP on its own, unless you spend months
    developing an HTML renderer.

    How about scripting a web browser? You can install Mozilla on the
    server, and your PHP program can ask it to render the page, print it to
    PostScript, and then use ImageMagick to convert that to the image format
    of your choice.

    miguel
    --
    Photos from 40 countries on 5 continents: http://travel.u.nu
    Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
    Airports of the world: http://airport.u.nu

    Comment

    • Csaba Gabor

      #3
      Re: How to create a snapshot of a URL in PHP?

      Miguel Cruz wrote:
      "BG Mahesh" <mahesh@mahesh. comwrote:
      Given a URL I want the snapshot of that page as an image. Something
      like

      ttp://google.com

      How do I achieve this in PHP?
      >
      You can't, at least not with PHP on its own, unless you spend months
      developing an HTML renderer.
      >
      How about scripting a web browser? You can install Mozilla on the
      server, and your PHP program can ask it to render the page, print it to
      Hi Miguel. I'm not the OP, but would you please elaborate on how you
      would get Mozilla to do this?

      One possible approach is with a GreaseMonkey type of solution. But can
      you use GM with javascript turned off? I have not investigated this.
      I think one should have javascript turned off in deciding what,
      exactly, to render, else you can run the javascript into a hole with an
      alert.

      One could also bring up Mozilla/FF directly with a page, but then I
      don't know how to programatically direct it.

      With IE ($ie=new COM("InternetEx plorer.Applicat ion")) one can bring up
      an instance of IE and load a page
      ($ie->Navigate2("htt p://www.myFavoriteD omain.com")), but I haven't
      tried saving saving this (and it doesn't show me an option to save as
      an image).

      That is, in neither FF nor IE do I see the option to save the page as a
      Postscript page or anything I would construe as an image. Where do I
      look for this?

      Csaba Gabor from Vienna

      Comment

      • Miguel Cruz

        #4
        Re: How to create a snapshot of a URL in PHP?

        "Csaba Gabor" <danswer@gmail. comwrote:
        Miguel Cruz wrote:
        >How about scripting a web browser? You can install Mozilla on the
        >server, and your PHP program can ask it to render the page, print it
        >
        Hi Miguel. I'm not the OP, but would you please elaborate on how you
        would get Mozilla to do this?
        Sounds like you're using Windows. Unfortunately I'm probably not the
        best person to help you, as I'm using a Mac. With AppleScript it's
        pretty trivial to do this, then just invoke the AppleScript with PHP.

        Some possible leads for the platform-impaired to check out:





        miguel
        --
        Photos from 40 countries on 5 continents: http://travel.u.nu
        Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
        Airports of the world: http://airport.u.nu

        Comment

        • Adam Harvey

          #5
          Re: How to create a snapshot of a URL in PHP?

          On Tue, 01 Aug 2006 05:22:37 +0800, Miguel Cruz wrote:
          Sounds like you're using Windows. Unfortunately I'm probably not the
          best person to help you, as I'm using a Mac. With AppleScript it's
          pretty trivial to do this, then just invoke the AppleScript with PHP.
          Another option may be to use the Firefox extension Page Saver
          <http://pearlcrescent.c om/products/pagesaver/>, which apparently has some
          command-line options to generate a PNG from a URL. I've only used the
          in-browser options, myself, but it seems to produce pretty good output.

          Not affiliated with them, may blow up in your face, insert your favourite
          disclaimer here. :)

          Adam

          --
          Adam Harvey

          To e-mail: don't make an example out of me!

          Comment

          Working...