Hi There
I am hoping that there is someone that can help me and many others with this problem...
I want to create a screenshot of a website using the imagegrabwindow function part of php and the GD library
After spending the whole day implementing the code I finally can capture the image and save it to a file, but the image is black and not the image that I expected...
On further investigation I have learned that one of the reasons why the image is black is because apache is not turned on to interact with the desktop - and because of this creates a black image - The issue is I am not running Apache as a server I am running IIS 6...
Is there a setting in Services that I should allow to interact with the desktop? and if there is can somebody point me in the right direction?
<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate("http://localhost/site/advertise/index.asp");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
imagepng($im, "iesnap6.jpg");
$browser->Quit();
?>
Thanks to the answers below I have changed imagepng to imagejpeg - But still get a black image...
imagejpeg($im, "iesnap7.jpg");
Any help would be much appreciated!
Thanks
I have ammended the code to this: Social Addict still no success with the image showing up in Black!
<?php
header('Content-type: image/jpeg');
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://localhost/advertise/index.asp");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagejpeg($im," file2.jpg");
imagedestroy($im);
?>
Social Addict - I have added the header - I am also constantly changing the file1.jpg name to make sure it is not using a black cached images... still no luck!