Anonymouse February 2016

Using ProcessStartInfo with ImageMagick's Mogrify

Tearing my hair out over something that should be ridiculously simple! I have cd'd to C:\Program Files\ImageMagick-6.9.0-Q16 on my shell and used the following the command string which works on my machine; it creates the expected output image, no problem:

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

I am trying to automate this with a simple test application in 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();

I have tried several permutations of this, using convert.exe, mogrify.exe, with verb as "runas", with the working directory set on, or off... (see commented out stuff - I've tried setting it) I have referred to how to use imageMagick with C# but I continue to get the same error:

mogrify.exe: unable to open image convert': No such file or directory @ error/blob.c/OpenBlob/2709. mogrify.exe: no decode delegate for this

Answers


Anonymouse February 2016

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();

I'm not actually sure why this works instead of the original question, but it does. Using convert.exe is indeed correct, not mogrify.exe. As an FYI, the other parameters are ShellExecute = false, Redirect std err/out are set to true, verb is runas.

Post Status

Asked in February 2016
Viewed 3,429 times
Voted 14
Answered 1 times

Search




Leave an answer