PHP---php using the GD library for screenshot _php tutorial

Source: Internet
Author: User
PHP uses GD library for screenshot
PHP5.2.2 above version of the GD library implemented two screenshots functions Imagegrabscreen and Imagegrabwindow
Screens that intercept the entire screen and intercept a window (same alt+printscreen), respectively.
1. Capture the entire screen screenshot
$im = Imagegrabscreen ();
Imagepng ($im, "myscreenshot.png");
?>
2. Capturing a window capture a Windows (IE for example)
$browser = new COM ("Internetexplorer.application");
$handle = HWND $browser;
$browser, Visible = true;
$im = Imagegrabwindow ($handle);
$browser, Quit ();
Imagepng ($im, "iesnap.png");
$im = Imagegrabscreen ();
?>
3. Capturing IE content capture a window (ie for example) but with its content!
$browser = new COM ("Internetexplorer.application");
$handle = HWND $browser;
$browser, Visible = true;
$browser-Navigate ("http://www.21andy.com/blog/");

/* Still working? */
while ($browser-Busy) {
Com_message_pump (4000);
}
$im = Imagegrabwindow ($handle, 0);
$browser, Quit ();
Imagepng ($im, "iesnap.png");
?>
4. Capture IE's full-screen mode ie in fullscreen modes
$browser = new COM ("Internetexplorer.application");
$handle = HWND $browser;

$browser, Visible = true;
$browser-fullscreen = true;
$browser-Navigate ("http://www.21andy.com/blog/");

/* Is it completely loaded? (Be aware of frames!) */
while ($browser-Busy) {
Com_message_pump (4000);
}
$im = Imagegrabwindow ($handle, 0);
$browser, Quit ();
Imagepng ($im, "iesnap.png");
?>
I use Internet Example Explorer as Example, if you like to play more with IE and COM, check out the IBrowser2 documentatio N at MSDN. It should work with any kind of windows as long as you give the correct handle (usually $obj->hwnd).
* Php_gd2.dll for 5.2.x thread safe build
* PHP GD Image documentation
* IE Manual (useful to tweak it from com_dotnet

During the test I did not appear in the manual that the effect, but a pure black picture, this is why?
There may be two situations in which the first case is that the COM component applies only to Windows servers, because he does not have IE, and the second scenario is that the Allow service to interact with the desktop is not turned on! The second is the most common (by default, closed), open by: Click the computer (My Computer), right---manage services and applications, services and apps, Apache---Login-&G T Check allow services to interact with the desktop.

If this is the second case, I installed the Apache integration package, so that I can not find the Apache service where, so the second method of setting I did not succeed, if there is a successful person, want to point.

Excerpted from plastic sheets

http://www.bkjia.com/PHPjc/478304.html www.bkjia.com true http://www.bkjia.com/PHPjc/478304.html techarticle PHP using the GD library to achieve the screenshot PHP5.2.2 version of the GD library implemented two screenshots function Imagegrabscreen and Imagegrabwindow respectively for intercepting the entire screen and intercepting a window (with Alt ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.