Pouya BCD
Pouya BCD

Reputation: 1031

Calling Image Magick commands from .Net

I am trying call a Image Magick inside a .NET app. It is very strange that when I copy the same arguments and use command line to call it. It is OK but when I call it by my C# app, I get the error at the end. I don't know how come it expects a Affine argument when I call it by my app. Please help.

  var proc = new Process
   {
      StartInfo = new ProcessStartInfo
     {
    FileName = @"C:\Program Files (x86)\ImageMagick-6.8.4-Q16\convert.exe",
    Arguments = "\"C:\\Users\\Pouya\\Desktop\\Rugs\\test.jpg\" -matte -virtual-pixel transparent -distort Perspective ' 2,2 0,0 2,198 0,200 198,198 200,200 198,2 200,0' \"C:\\Users\\Pouya\\Desktop\\Rugs\\testResult.jpg\"",
    UseShellExecute = false,
    RedirectStandardError = true,
    CreateNoWindow = true
     }
   };

 proc.Start();`

"convert.exe: invalid argument for option Affine : 'require at least 1 CPs' @ error/distort.c/GenerateCoefficients/530.\r\nconvert.exe: unable to open image 2,2': No such file or directory @ error/blob.c/OpenBlob/2641.\r\nconvert.exe: no decode delegate for this image format2,2' @ error/constitute.c/ReadImage/550.\r\nconvert.exe: unable to open image 0,0': No such file or directory @ error/blob.c/OpenBlob/2641.\r\nconvert.exe: no decode delegate for this image format0,0' @ error/constitute.c/ReadImage/550.\r\nconvert.exe: unable to open image 2,198': No such file or directory @ error/blob.c/OpenBlob/2641.\r\nconvert.exe: no decode delegate for this image format2,198' @ error/constitute.c/ReadImage/550.\r\nconvert.exe: unable to open image 0,200': No such file or directory @ error/blob.c/OpenBlob/2641.\r\nconvert.exe: no decode delegate for this image format0,200' @ error/constitute.c/ReadImage/550.\r\nconvert.exe: unable to open image 198,198': No such file or directory @ error/blob.c/OpenBlob/2641.\r\nconvert.exe: no decode delegate for this image format198,198' @ error/constitute.c/ReadImage/550.\r\nconvert.exe: unable to open image 200,200': No such file or directory @ error/blob.c/OpenBlob/2641.\r\nconvert.exe: no decode delegate for this image format200,200' @ error/constitute.c/ReadImage/550.\r\nconvert.exe: unable to open image 198,2': No such file or directory @ error/blob.c/OpenBlob/2641.\r\nconvert.exe: no decode delegate for this image format198,2' @ error/constitute.c/ReadImage/550.\r\nconvert.exe: unable to open image 200,0'': No such file or directory @ error/blob.c/OpenBlob/2641.\r\nconvert.exe: no decode delegate for this image format200,0'' @ error/constitute.c/ReadImage/550.\r\n"

Upvotes: 0

Views: 1551

Answers (1)

PinnyM
PinnyM

Reputation: 35531

Change the single quotes around ' 2,2 0,0 2,198 0,200 198,198 200,200 198,2 200,0' to escaped double quotes. Also get rid of the extra leading space immediately after the first quote:

\"2,2 0,0 2,198 0,200 198,198 200,200 198,2 200,0\" 

Upvotes: 1

Related Questions