我试图使用imagemagick命令“转换”从.png创建一个.tif图像。Php执行命令转换图像
什么,我跟是:
$exec = "/opt/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif";
exec($exec);
如果我碰上CLI“其将”我得到的路径:/opt/local/bin/convert
。我也试过没有路径,只有/opt/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif
和/etc/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif
。
如果我运行该命令到终端,它按预期工作,但是当我试图从PHP脚本使用它时,它不起作用。
编辑: 我也尝试没有成功创建与下面的代码sh文件:
#! /bin/bash
convert -adaptive-resize 150% 1.png 1.tif
convert -adaptive-resize 150% 2.png 2.tif
convert -adaptive-resize 150% 3.png 3.tif
convert -adaptive-resize 150% 4.png 4.tif
convert -adaptive-resize 150% 5.png 5.tif
convert -adaptive-resize 150% 6.png 6.tif
convert -adaptive-resize 150% 7.png 7.tif
convert -adaptive-resize 150% 8.png 8.tif
convert -adaptive-resize 150% 9.png 9.tif
如果我从终端运行它,它就像一个魅力。 相反,如果我尝试从简单的PHP文件执行它,它不会创建任何.tif文件。
<?php
$exec = "./convertpngtif.sh";
exec($exec);
?>
执行var_dump($ exec)查看生成的内容,可能是空格问题 – JorgeeFG
string(56)“/ opt/local/bin/convert -adaptive-resize 150%1.png 1.tif“ – KingBOB
试试这些:'error_reporting(E_ALL);后续代码var_dump($ _ SERVER); echo getcwd();',也看看apache的error.log。 –