Exec imagemagick convert via c #

When I open a command window in windows and use the imagemagick convert command:

convert / somedir / Garden.jpg / somedir / Garden.png

Works as expected.

What I am trying to do is execute the same command as above using C #.

I tried using System.Diagnostics.Process, however foo.png is not generated.

I am using this code:

      var proc = new Process
          StartInfo =
              Arguments = string.Format("{0}Garden.jpg {1}Garden.png",
              FileName = @"C:\xampp\ImageMagick-6.5.4-Q16\convert",
              UseShellExecute = false,
              CreateNoWindow = true,
              RedirectStandardOutput = false,
              RedirectStandardError = false



No exception is thrown, but a .png is written as well.


source to share

1 answer

I assume it TEST_FILE_DIR

contains a space, so you should quote it.

Try the following:

Arguments = string.Format("\"{0}Garden.jpg\" \"{1}Garden.png\"",


You can also specify the filename including the extension, for example

FileName = @"C:\xampp\ImageMagick-6.5.4-Q16\convert.exe"




All Articles