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).

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

报告相同问题?

悬赏问题

  • ¥15 nslt的可用模型,或者其他可以进行推理的现有模型
  • ¥15 arduino上连sim900a实现连接mqtt服务器
  • ¥15 vncviewer7.0安装后如何正确注册License许可证,激活使用
  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并2
  • ¥66 关于人体营养与饮食规划的线性规划模型
  • ¥15 基于深度学习的快递面单识别系统
  • ¥15 Multisim仿真设计地铁到站提醒电路
  • ¥15 怎么用一个500W电源给5台60W的电脑供电
  • ¥15 请推荐一个轻量级规则引擎,配合流程引擎使用,规则引擎负责判断出符合规则的流程引擎模板id
  • ¥15 Excel表只有年月怎么计算年龄