Results 1 to 3 of 3

Thread: url screenshot php

  1. #1
    Join Date
    Nov 2007
    Location
    Tavira - Algarve - Portugal
    Posts
    25

    Default url screenshot php

    Hello,
    I try to take url screenshots in php, and I try a script from php site with the fuction imagecreatefromjpeg, like this one:
    PHP Code:
    <?
    Header( "Content-Type: image/jpeg");
    function LoadJPEG ($imgURL) {
        ##-- Get Image file from Port 80 --##
        $fp = fopen($imgURL, "r");
        $imageFile = fread ($fp, 3000000);
        fclose($fp);
        ##-- Create a temporary file on disk --##
        $tmpfname = tempnam ("/temp", "IMG");
        ##-- Put image data into the temp file --##
        $fp = fopen($tmpfname, "w");
        fwrite($fp, $imageFile);
        fclose($fp);

        ##-- Load Image from Disk with GD library --##
        $im = imagecreatefromjpeg ($tmpfname);

        ##-- Delete Temporary File --##
        unlink($tmpfname);

        ##-- Check for errors --##
        if (!$im) {
            print "Could not create JPEG image $imgURL";
        }
        return $im;
    }
    $imageData = LoadJPEG("http://www.google.com");
    imagejpeg($imageData, '', 100);
    ?>
    But when I execute the script not appear any image contain the url screenshot.
    If I execute the script in the script page (imagem_url.php) appear this phrase:"http://fotos.gloradin.com/experiencia/2/imagem_url.php".

    If I call the image in other page don't appear anything, just a blank page.

    I think I have to change something in the php.ini for authorize the image url capture, but I don't know what I have to change.

    If the reason not is php.ini, what kind of problem my script have?

    The best regards,
    gloradin
    Last edited by gloradin; 05-06-2008 at 03:09 PM.

  2. #2

    Default Omg

    When I saw your post title, I was more than happy because someone can do it in PHP. However, your method is not correct, when you use fopen to open a URL, you will only get the HTML! How can you expect to get the actually rendered graphic of that webpage?

  3. #3

    Default

    Uhhh... yes... what you are trying to do is waaaaaaaaaaaay more complex than that! What you are attempting is a screen grab of a page as it might be rendered in a web browser

    Off the top of my head I'd be looking at piping a wget into some sort of screen capture ( standalone... not web based ) application, or running a dedicated box that can fire up an instance of a web browser and "snapshot" the url.

    Alternative is to use one of those free site testing services that do a snapshot, and download the image from there... but usually there is a delay unless you give them $$.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •