Calling Image Magick commands from .Net

旧巷老猫 提交于 2019-12-25 03:39:42

问题


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"


回答1:


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\" 


来源:https://stackoverflow.com/questions/16028228/calling-image-magick-commands-from-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!