php exec() 无法使用正确的命令
我在 Windows 7 上使用 xampp 来开发我的程序,但遇到了问题。
我尝试通过 exec() 函数启动 ImageMagick。
这是我的代码。
<?php
$command = 'convert '.$tempOverlay.' '.$tempBg.' -compose Overlay -composite '.$tempImage;
exec($command);
die($command);
?>
如果我在正确的文件夹中的cmd中输入填充的$命令(convert temp/100000231446889-overlay.jpg temp/100000231446889-bg.jpg -compose Overlay -composite temp/100000231446889.jpg)完美,但是通过 php 执行它,我没有得到任何输出图像魔术师。
我通过“Echo %CD%”检查了它是否在正确的文件夹中执行,但它是正确的文件夹。
I'm using xampp on windows 7 to develop my programs but I've got a problem.
I try to start ImageMagick via the exec() function.
Here is my Code sniped.
<?php
$command = 'convert '.$tempOverlay.' '.$tempBg.' -compose Overlay -composite '.$tempImage;
exec($command);
die($command);
?>
If i enter the filled $command (convert temp/100000231446889-overlay.jpg temp/100000231446889-bg.jpg -compose Overlay -composite temp/100000231446889.jpg)in my cmd in the right folder its works perfectly, but with it executed by php i get no output of ImageMagick.
I checked if its executed in the right folder via ' Echo %CD%' but its the right folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您安装 imagemagick 的 dll 版本时,可能会发生这种情况。您需要安装静态版本。无论为什么发生这种情况,当通过 php 调用时,imagemagick 无法加载自己的 dll,并且 imagemagick 的错误输出不会发送到标准输出。它转到 stderr。所以你无法从 php.ini 中看到这一点。
This can happen, when you install the dll version of imagemagick. You need to install the static version. Whyever that happens, imagemagick cannot load its own dlls when called over php and the error output of imagemagick goes not to the stdout. It goes to stderr. So you cannot see that from php.
一个好的镜头是避免相对路径。使用完整路径进行测试。
它确实看起来像一个路径问题...
或者用 PHP 捕获的 cd + dir 增加 exec 命令。
A nice shot would be avoid relative path. Use full path for a test.
It really looks like a path problem...
Or increment exec command with cd + dir caught with PHP.