为什么从 PHP 脚本调用 (ImageMagick) Convert.exe 会导致页面无响应?

发布于 2024-07-24 04:26:31 字数 910 浏览 8 评论 0原文

* 现在已通过清除 Windows 中的临时文件夹解决了这个问题 *

一些信息 - Windows 2003 服务器、IIS 6 ImageMagick 6.3.3 PHP 5.2.0

我正在使用 ImageMagick 调整服务器上图像的大小,我认为这最近引起了问题。 我注意到,当我的 PHP 脚本执行 ImageMagick 命令时,网页会冻结并且不会重新加载。 事实上,我发现我必须先清除缓存和 cookie,然后才能重新加载页面并重试。 我已将问题隔离到调用 imageMagick Convert.exe 的代码行。 我没有得到任何响应,并使用 Mozilla Firebug 查看流量,我可以看到没有返回数据,没有有关被调用页面的信息,只是它似乎挂起。

调用 ImageMagick 的代码没有改变,并且之前一直有效(大约 2 年!),如下 -

   $cmd = "convert.exe \"". $uploadfile . "\" -resize \"" . res_image_width ."x" . res_image_height . ">\" \"". $uploadfile. "\" 2>&1";
   passthru($cmd);
   //system($cmd);
   //exec($cmd);

(我通常使用 passthru,但我尝试了 exec 和 system 来看看是否可以返回一些信息。)

我可以运行 ImageMagick来自命令行的命令没有问题,并且图像大小调整得很好...所以 ImageMagick 似乎工作正常,它似乎只是 PHP -> 。 这就是ImageMagick 通信的问题。 我希望重新启动可以解决它。 你知道还有什么可能吗? 我将如何调试这个?

非常感谢

* This is now resolved * by clearing the temp folder in windows!

Some info -
Windows 2003 server, IIS 6
ImageMagick 6.3.3
PHP 5.2.0

I am using ImageMagick to resize images on the server and I think this has recently been causing problems. What I am noticing is that when my PHP script executes the ImageMagick command the webpage freezes and will not reload. In fact I found that I have to clear the cache and cookies before I am able to reload the page and try again. Ive isolated the problem to the line of code that calls the imageMagick convert.exe. I get no response and using Mozilla Firebug to look at the traffic I can see that there is no data returned, no information about the page being called, simply it seems to hang.

The code that calls ImageMagick has not changed and has always worked previously (about 2 years!) and is as follows -

   $cmd = "convert.exe \"". $uploadfile . "\" -resize \"" . res_image_width ."x" . res_image_height . ">\" \"". $uploadfile. "\" 2>&1";
   passthru($cmd);
   //system($cmd);
   //exec($cmd);

(I have normally used passthru but I tried exec and system to see if I could return some info. )

I can run ImageMagick commands from the command line no problem and images get resized fine... so ImageMagick seems to be working fine, it just appears to be the PHP -> ImageMagick communication that is the problem. Im hoping restarting might solve it. Do you know anything else it could be? How would I go about debugging this?

many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤檠 2024-07-31 04:26:31

您可以使用 passthru 运行其他命令吗? 例如: passthru("dir");

并且 res_image_width 应该是 $res_image_width 吗? 确保已启用 error_reporting(在脚本顶部包含 error_reporting(E_ALL);)。

Are you able to run other commands using passthru? e.g: passthru("dir");

And is res_image_width supposed to be $res_image_width? Make sure you have error_reporting enabled (include error_reporting(E_ALL); at the top of your script).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文