簡體   English   中英

在ImageMagick的Mogrify中使用ProcessStartInfo

[英]Using ProcessStartInfo with ImageMagick's Mogrify

扯掉我的頭發,這簡直太簡單了! 我已經在我的外殼上CD到C:\\ Program Files \\ ImageMagick-6.9.0-Q16,並使用了以下在我的機器上可以使用的命令字符串; 它會創建預期的輸出圖像,沒問題:

轉換“ C:\\ Users \\ someguy \\ Debug \\ test_in.jpg”-調整大小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”,打開或關閉了工作目錄...(請參閱注釋掉的東西-我嘗試設置它)已經提到了如何在C#中使用imageMagick,但是我仍然遇到相同的錯誤:

mogrify.exe:無法打開圖像convert': No such file or directory @ error/blob.c/OpenBlob/2709. mogrify.exe: no decode delegate for this image format 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 convert': No such file or directory @ error/blob.c/OpenBlob/2709. mogrify.exe: no decode delegate for this image format mogrify.exe:無法打開圖像`C:\\ Users \\ someguy \\ Debug \\ test_out.jpg':沒有這樣的文件或目錄@ error / blob.c / OpenBlob / 2709。

我覺得我只是在這里錯過了一些非常基本的東西,但是目前我還沒有任何線索。 有人可以提出建議嗎?

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,重定向標准錯誤/輸出設置為true,動詞為runas。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM