gpt4 book ai didi

php - 带有 php exec 的 CutyCapt

转载 作者:可可西里 更新时间:2023-10-31 23:32:24 25 4
gpt4 key购买 nike

我在我的 CentOS 上使用 CutyCapt。它通过终端可以正常工作,但不能通过 php exec 函数工作。我已经在终端中通过命令启动了 xvfb:

Xvfb :99 -screen 0 1024x768x24

我正在尝试通过 php 脚本截屏:

exec("DISPLAY=:99 /path/to/cutycapt --url=<some url> --out=<path/to/output>");

它没有显示任何错误但没有输出文件(输出目录有 chmod 777)有人可以帮助我吗?

谢谢

更新:也许以某种方式允许 Apache 执行 Xvfb 会更好?

最佳答案

最后,我设法让 CutyCapt 使用 php 成功运行。 $_parameters 通过 AJAX 传递给 php 脚本。希望这有助于...

 case 'Output_Chart': {

// We always create the .png. We use the ImageMagick convert (IMC) command to make .pdfs
if ($_Suffix == 'pdf') {
$IMC = ";convert -page 735x850 '$_PathOut/$_ChartName.png' '$_PathOut/$_ChartName.pdf'";
} else {
$IMC = '';
}

// Prepare the query string for the CutyCapt URL
$sQuery_Pattern = '?Path=%s&iDL=%d';
$sQuery = sprintf($sQuery_Pattern, $_Path, $_iDL);

// Prepare CutyCapt's command and parameters (NB: query string and out parameter are enclosed in aposts for the shell)
$sCC_Cmd = '/var/www/LF/Includes/CutyCapt';
$sCC_URL = "http://localhost/LF/LFPrint.html'$sQuery'"; // Note: Inner apostrophes
$sCC_Out = "'$_PathOut/$_ChartName.png'";
$sCC_Pattern = ' --url=%s --out=%s --delay=%d --min-width=%d';
$sCC_Options = sprintf($sCC_Pattern, $sCC_URL, $sCC_Out, $_Delay, $_MinWidth);
//$sCC_CmdLine = $sCC_Cmd . $sCC_Options . " 2> CutyCapt.err.txt";
$sCC_CmdLine = $sCC_Cmd . $sCC_Options . " 2> /dev/null";

// Prepare the final command line with xvfb-run, CutyCapt, and the URL?QueryString
$sCC_CmdLine = 'xvfb-run --auto-servernum --server-args="-screen 0, 800x1000x24" ' . $sCC_CmdLine . $IMC;
exec( $sCC_CmdLine, $aOutput = array(), $ret);
// Wait for and then return the results. sCC_CmdLine and aOutput are just for debugging
echo json_encode(array("ret" => $ret, "cmd" => $sCC_CmdLine, "Output" => $aOutput));
break;
}

关于php - 带有 php exec 的 CutyCapt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15116030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com