Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Nov 2007
    Posts
    61
    Thanks
    0
    Thanked 6 Times in 6 Posts

    can imagegrabscreen() actually capture pages with content loaded?

    Hi folks and folksesses,

    In the GD2 library there is a function called 'imagegrabscreen()' and 'imagegrabwindow()', which captures a screen dump of the current window, or another one specified by the code.

    The only problem is that it launches the function as soon as the page is loaded, which means the target page, which is being grabbed hasn't actually loaded at the time of the screen grab. So all you are left with is an image of a blank page. Which renders it slightly pointless.

    Is there any way you can get the code to sleep until the screen/window (to be grabbed) has loaded, so it actually contains the content?

    Thanks,

    Sam

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    hmm, interesting problem.

    have you tried: usleep() ?
    that *might* work.

    http://www.php.net/usleep

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I just noticed this note in the manual:
    "Note: This function is only available on Windows."

    I'm guessing that means a Windows server (not UNIX)?

    I haven't tried the imagegrabscreen myself either.

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ah, i didn't even notice that message.

  • #5
    New Coder
    Join Date
    Nov 2007
    Posts
    61
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by mlseim View Post
    I just noticed this note in the manual:
    "Note: This function is only available on Windows."

    I'm guessing that means a Windows server (not UNIX)?

    I haven't tried the imagegrabscreen myself either.

    Hmm.. yeah, good point! Just tested it.. it works on my Apache xaamp.. but not on my web host.. Ah well, it was a good idea.

    Thanks guys,
    Sam

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    darn it ...

    The first post sort of excited me because I hadn't seen that before.

    My webhosts are UNIX ... rats!

  • #7
    New Coder
    Join Date
    Apr 2007
    Posts
    89
    Thanks
    1
    Thanked 2 Times in 2 Posts
    sleep() works on *nix though as it's an inbuilt function and all there are some possibly useful comments on the man page

  • #8
    New Coder
    Join Date
    May 2007
    Location
    Manchester, UK
    Posts
    72
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Why on earth would you want to grab a screenshot from your "UNIX" (most likely Linux, but anyway) host?

    1) You're not running any graphical apps on the server (are you?!)
    2) The server probably doesn't even have the pointless overhead of a windowing system
    Every PHP programmer of any skill level should set error_reporting(E_ALL); at the top of their scripts or in their php.ini

  • #9
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,027
    Thanks
    2
    Thanked 315 Times in 307 Posts
    psykx and Ahri - did either of you read this thread, starting with the title and the first post or investigate what 'imagegrabscreen()' and 'imagegrabwindow()' were in the php manual?

    psykx - the issue does not have anything to do with the sleep() function being present on *nix based systems

    Those of us that looked up the imagegrabwindow() function in the php manual, noticed that it uses COM to invoke an instance of an application (such as a web browser and open a web page in it) and allows you to capture a screen shot of the results.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #10
    New Coder
    Join Date
    May 2007
    Location
    Manchester, UK
    Posts
    72
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by CFMaBiSmAd View Post
    psykx and Ahri - did either of you read this thread, starting with the title and the first post or investigate what 'imagegrabscreen()' and 'imagegrabwindow()' were in the php manual?

    psykx - the issue does not have anything to do with the sleep() function being present on *nix based systems

    Those of us that looked up the imagegrabwindow() function in the php manual, noticed that it uses COM to invoke an instance of an application (such as a web browser and open a web page in it) and allows you to capture a screen shot of the results.
    Sorry, I forgot to make it clear that I was addressing mlseim.
    Every PHP programmer of any skill level should set error_reporting(E_ALL); at the top of their scripts or in their php.ini

  • #11
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Ahri ...

    I think UNIX in this case means what my webhost is running to
    serve my webpages. The screenshot is actually a screenshot of
    the webpage that is getting served to the user.

    My website/PHP/GD needs to be on a Windows server.

    .... at least that's what I assume the notation means in the GD manual.


  •  

    Posting Permissions

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