dougui5419 2011-01-18 11:31
浏览 26
已采纳

如何在unix(debian)中使用php创建内存屏幕捕获

The following code, is only available on windows.

<?php
  ...
  $im = imagegrabwindow($handle);
  ...      
  imagedestroy($im);
?>

Whats the solution on unix (debian) php environment, get the screen capture at a php cli programm?

  • 写回答

1条回答 默认 最新

  • douqiu9529 2011-01-18 13:13
    关注

    So, it sounds like you want to capture screens from Firefox :p.

    For a headless server, make sure Xvfb is installed first, then start it with Xvfb :2 -screen 0 1024x768x24& (you can change the display :2 and resolution 1024x768x24 as needed of course).

    Run Firefox to open a specific page on that display DISPLAY=:2 firefox http://www.example.com. Wait a bit for Firefox to open the page, so execute a sleep 10 or something similar.

    And then throw in some "magic" from ImageMagick (which has to be installed of course) to capture the screen to a file : import -window root -display :2 example.png.

    And now your processing fun starts :p.

    Here's a small bash script putting it all together (Xvfb should already be running though for it to work) :

    #!/bin/bash
    export DISPLAY=":2" /usr/bin/firefox "$1"&
    /bin/sleep 10
    /usr/bin/import -window root -display :2 "$2"
    killall firefox-bin
    

    Call that from PHP, and provide it with the URL and filename of the screenshot as parameters.

    btw If your server has X you can skip the Xvfb part and use the running X server display (most probably :0).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!