我试图运行这段代码,它到目前为止一直是代码,直到代码尝试执行一个函数来从临时文件创建一个pic。这里效果不好:
// create temporary latex file
$fp = fopen($this->_tmp_dir."/".$this->_tmp_filename.".tex","a+");
fputs($fp,$latex_document);
fclose($fp);
// create temporary dvi file
$command = $this->_latex_path." --interaction=nonstopmode ".$this->_tmp_filename.".tex";
$status_code = exec($command);
if (!$status_code) { $this->cleanTemporaryDirectory(); chdir($current_dir); $this->_errorcode = 4; return false; }
// convert dvi file to postscript using dvips
$command = $this->_dvips_path." -E ".$this->_tmp_filename.".dvi"." -o ".$this->_tmp_filename.".ps";
$status_code = exec($command);
// imagemagick convert ps to image and trim picture
$command = $this->_convert_path." -density ".$this->_formula_density.
" -trim -transparent \"#FFFFFF\" ".$this->_tmp_dir."/".$this->_tmp_filename.".ps ".
$this->_tmp_dir."/".$this->_tmp_filename.".".$this->_image_format;
$status_code = exec($command);
$latexlog = fopen($this->_tmp_dir."/latex.log","a+");
fputs($latexlog,$command);
fclose($latexlog);
// test picture for correct dimensions
$dim = $this->getDimensions($this->_tmp_filename.".".$this->_image_format);
if ( ($dim["x"] > $this->_xsize_limit) or ($dim["y"] > $this->_ysize_limit)) {
$this->cleanTemporaryDirectory();
chdir($current_dir);
$this->_errorcode = 5;
$this->_errorextra = ": " . $dim["x"] . "x" . number_format($dim["y"],0,"","");
return false;
}
// copy temporary formula file to cahed formula directory
$latex_hash = md5($latex_formula . ";fd=" . $this->_formula_density);
$filename = $this->getPicturePath()."/".$latex_hash.".".$this->_image_format;
$latexlog = fopen($this->_tmp_dir."/latex1.log","a+");
fputs($latexlog,$filename);
fclose($latexlog);
$status_code = copy($this->_tmp_filename.".".$this->_image_format,$filename);
和latex1.log的内容是:
C:\inetpub\wwwroot\tiki/lib/equation/pictures/35d8c95bf51a397b06a20078c95f8ff4.png"C:\inetpub\wwwroot\tiki/lib/equation/pictures/35d8c95bf51a397b06a20078c95f8ff4.png"
和latex.log:
"C:/Program Files/ImageMagick-7.0.5-Q16/convert.exe" -density 120 -trim -transparent "#FFFFFF" C:\inetpub\wwwroot\tiki/lib/equation/tmp/e940a3ba6df738388b772344a8a112e4.ps C:\inetpub\wwwroot\tiki/lib/equation/tmp/e940a3ba6df738388b772344a8a112e4.png"C:/Program Files/ImageMagick-7.0.5-Q16/convert.exe" -density 120 -trim -transparent "#FFFFFF" C:\inetpub\wwwroot\tiki/lib/equation/tmp/8671e7b4d35f3d498f22e225dbe70bd9.ps C:\inetpub\wwwroot\tiki/lib/equation/tmp/8671e7b4d35f3d498f22e225dbe70bd9.png
除了html中的错误:
PHP (5.6.30) ERROR (E_WARNING):
File: C:\inetpub\wwwroot\tiki\lib\equation\class.latexrender.php
Line: 284
Type: copy(8671e7b4d35f3d498f22e225dbe70bd9.png): failed to open stream: No such file or directory
答案 0 :(得分:0)
看起来您可能正在使用Windows中的Linux系统上执行的代码。我猜这是因为图像的路径混合了/
和\
:
C:\inetpub\wwwroot\tiki/lib/equation/pictures/35d8c95bf51a397b06a20078c95f8ff4.png"C:\inetpub\wwwroot\tiki/lib/equation/pictures/35d8c95bf51a397b06a20078c95f8ff4.png"
您可以尝试使用\
,或者使用PHP常量DIRECTORY_SEPARATOR
。如果您在使用它们之前添加了所有files exists的检查,那么它可能有助于您的调试。