2016-02-08 106 views
0

將我的頭髮甩出應該簡單可笑的東西!我已經在我的shell上cd到C:\ Program Files \ ImageMagick-6.9.0-Q16,並使用下面的命令字符串,它在我的機器上工作;它產生預期的輸出圖像,沒有任何問題:在ImageMagick的Mogrify中使用ProcessStartInfo

convert "C:\Users\someguy\Debug\test_in.jpg" -resize 75x75 -colorspace RGB "C:\Users\someguy\Debug\test_out.jpg"

我想在C#一個簡單的測試應用程序自動完成:

var proc = new Process 
      { 
       StartInfo = new ProcessStartInfo() 
       { 
        //WorkingDirectory = @"C:\Program Files\ImageMagick-6.9.0-Q16\", 
        Arguments = //_arguments, 
        "convert \"" + InputPath + "\" -resize 75x75 \"" + OutputPath + "\"" 
        , 
        UseShellExecute = _useShellExecute, 
        RedirectStandardError = _redirectStandardError, 
        //RedirectStandardOutput = _redirectStandardOutput, 
        //CreateNoWindow = _createNoWindow, 
        //Verb = _verb, 
        FileName = @"C:\Program Files\ImageMagick-6.9.0-Q16\" + "convert.exe" 
       } 
      }; 
      var test = proc.StartInfo.Arguments.ToString(); 
      proc.Start(); 
      string error = proc.StandardError.ReadToEnd(); 
      proc.WaitForExit(); 

我已經試過這幾個排列,使用CONVERT.EXE ,mogrify.exe,動詞爲「runas」,工作目錄設置爲打開或關閉...(請參見注釋掉的東西 - 我試過設置它)我提到了how to use imageMagick with C#,但我仍然得到相同的錯誤:

mogrify.exe: unable to open image convert': No such file or directory @ error/blob.c/OpenBlob/2709. mogrify.exe: no decode delegate for this image format ' @ error/constitute.c/ReadImage/501. mogrify.exe: unable to open image `C:\Users\someguy\Debug\test_out.jpg': No such file or directory @ error/blob.c/OpenBlob/2709.

我覺得我只是在這裏錯過了一些非常基本的東西,但我現在還沒有線索。有人可以提供一個建議嗎?

回答

0
var proc = new Process 
      { 
       StartInfo = new ProcessStartInfo(_imageMagickFile) 
       { 
        //WorkingDirectory = @"C:\Program Files\ImageMagick-6.9.0-Q16\", 
        Arguments = //_arguments, 
        "" + InputPath + " -resize 75x75 " + OutputPath + "" 
        , 
        UseShellExecute = _useShellExecute, 
        RedirectStandardError = _redirectStandardError, 
        RedirectStandardOutput = _redirectStandardOutput, 
        CreateNoWindow = _createNoWindow, 
        Verb = _verb, 
        FileName = _imageMagickFile 
       } 
      }; 
      var test = proc.StartInfo.Arguments.ToString(); 
      proc.Start(); 
      string error = proc.StandardError.ReadToEnd(); 
      proc.WaitForExit(); 

我實際上並不知道爲什麼這個工程,而不是原來的問題,但它確實。使用convert.exe確實是正確的,而不是mogrify.exe。作爲參考,其他參數是ShellExecute = false,Redirect std err/out設置爲true,verb是runas。