為什麼從 PHP 腳本調用 (ImageMagick) convert.exe 會導致頁面無響應? (Why is calling (ImageMagick) convert.exe from PHP script resulting in an unresponsive page?)


問題描述

為什麼從 PHP 腳本調用 (ImageMagick) convert.exe 會導致頁面無響應? (Why is calling (ImageMagick) convert.exe from PHP script resulting in an unresponsive page?)

* 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

‑‑‑‑‑

參考解法

方法 1:

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).

(by undefinedJoe Freeman)

參考文件

  1. Why is calling (ImageMagick) convert.exe from PHP script resulting in an unresponsive page? (CC BY‑SA 3.0/4.0)

#imagemagick #windows-server-2003 #PHP #iis-6 #passthru






相關問題

PHP ImageMagick setColorspace 不起作用 (PHP ImageMagick setColorspace not working)

從 Magick++ 圖像從內存 (libharu) 加載圖像 (Load Images from memory (libharu) from Magick++ images)

ImageMagick PDF to JPGs 有時會導致黑色背景 (ImageMagick PDF to JPGs sometimes results in black background)

使用 ImageMagick 改進從平面圖像到 3d 模型的轉換鏈 (Improve this conversion chain from flat images to 3d mockup with ImageMagick)

WampServer 和 Imagemagick,無法識別 imagick php 模塊 (WampServer and Imagemagick, imagick php module not recogized)

PHP Imagick - 顯示多圖像 TIFF 的第一片 (PHP Imagick - display first slice of mutli image TIFF)

打印 imagemagick 將輸出轉換為瀏覽器 (print imagemagick convert output to browser)

創建 ImageMagick Linux 腳本 (Create ImageMagick Linux script)

從照片生成漂亮的直方圖? (generating nice looking histogram from photo?)

iPhone中的imagemagick單色轉換 (imagemagick monochrome convert in iPhone)

為什麼從 PHP 腳本調用 (ImageMagick) convert.exe 會導致頁面無響應? (Why is calling (ImageMagick) convert.exe from PHP script resulting in an unresponsive page?)

如何使用 Python/ImageMagick/Wand 保存多層 PSD (How to save multi-layer PSD with Python/ImageMagick/Wand)







留言討論