0

我使用 wkhtmltoimage 截取页面的屏幕截图,但我的问题是为屏幕截图加载的页面会发出警报,其中包含我需要收听的有关裁剪的一些详细信息。有谁知道我如何使用 wkhtmltoimage 收听警报并获取要使用的详细信息。

我用 Cutycapt 做了类似的事情。这是我的命令

 $cutyResult = shell_exec('export DISPLAY=:99 && /usr/local/bin/wkhtmltoimage --width ' .$data['screenshots']['screenwidth']. ' --heigh ' .$data['screenshots']['screenheight']. ' ' . $url . ' /data/output.png && --expect-alert "screenshot" 2>&1 | grep crop')
 $cutyResult = trim($cutyResult);
 preg_match("/\[alert\] \"cropx=([0-9]+)&cropy=([0-9]+)&cropwidth=([0-9]+)&cropheight=([0-9]+)\"/", $cutyResult, $matches);
 print_r($matches);

但这似乎不是在等待警报?有任何想法吗?

4

1 回答 1

1

您可以从 Web 服务器的日志中最好地获取警报。

例如,如果您执行以下操作:

tail -f  /var/log/apache2/error.log

wkhtmltoimage: cannot connect to X server
or any error messages generated from the program. 

解析错误消息tailf并通过管道传输grep您正在寻找的错误。

于 2015-03-05T18:36:01.413 回答