/ Programming / 網頁/網站程式 / PHP /

利用 PHP 產生網站縮圖

New Subject
Random
Previous
Next
|
利用 PHP 產生網站縮圖

php 5.2.2 開始支援了 imagegrabwindow 及 imagegrabscreen 兩個截圖函式,imagegrabscreen 用於截取整螢幕,imagegrabwindow 用於截取某個視窗(同ALT+PrintScreen)。

imagegrabscreen用法:

程式項目名稱
  1. /* 原始程式碼 */
  2. <?php
  3. $im = imagegrabscreen();
  4. imagepng($im, "gd_screen.png");
  5. ?>

imagegrabwindow用法:

程式項目名稱
  1. /* 原始程式碼 */
  2. <?php
  3. $ie = new COM("InternetExplorer.Application") or die("Can't start Internet Explorer");
  4. try {
  5. $handle = $ie->HWND;
  6. $ie->Visible = true;
  7. $ie->Navigate("http://www.php.net");
  8. while ($ie->Busy) {
  9. com_message_pump(4000);
  10. }
  11. } catch (com_exception $e) {
  12. echo $e;
  13. }
  14. $im = imagegrabwindow($handle, 0);
  15. imagepng($im, "gd_window.png");
  16. $ie->Quit();
  17. ?>

注意!imagegrabwindow 這個截圖函式目前只支援 Windows 環境,Linux 下還不行,如果截圖只出現一張黑圖是因為沒有勾選選項:控制面板->管理工具->服務->你的apache服務->屬性->登陸->與桌面交互,選好了以後截圖代碼就可以正確運行了。

  • Keywords : imagegrabwindow, imagegrabscreen, 程式, 目名稱, 原始程式碼, imagepng, handle, 黑圖, 選好, 視窗, 管理工具, 登陸, 用於截取某, 環境, 注意, 桌面交互, 服務, 控制面板, 截圖函式, 屬性
0 0
2010-04-16T11:43:00+0000


  • Now, you can post comments by Facebook Account when your Yampiz account was logout or unvariable. whatever, we suggest to post comment by Yampiz Account to get more bounds to join new events of Heyxu
Comment
 
Verify

Archive DIR

    Facebook Page

    QR-Code and APP Launcher

    User Guide
    This Webpage

    In those service tabs, "Scan QRCode, in mobile device" or "Click the button, in this device" to open webpage or APP-related operations.
    QRCode
    • Auto Platform
      For better browsing experience, it will auto detects your device to display webpage.
    • Bug Report
      Tell us about the idea, problem and errors you found.
    • Comodo Secure
      The sensitive data transmission adopts by SSL-2048 authenticated encryption.
    • Copyright
      © 2009 YamPiz Digital Inc. & Jaby Group. All rights reserved.
    • Revised Version
      V2.2.207
      06 Jan 2025 (GMT+8)