从.Net调用Image Magick命令 [英] Calling Image Magick commands from .Net

查看:92
本文介绍了从.Net调用Image Magick命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在.NET应用程序中调用Image Magick.当我复制相同的参数并使用命令行调用它时,这很奇怪.可以,但是当我通过C#应用程序调用它时,最后出现错误.我不知道当我通过我的应用程序调用它时,为什么会期望Affine参数.请帮忙.

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:选项仿射无效的参数:'需要至少1个CP'@ error/distort.c/GenerateCoefficients/530.\ r \ nconvert.exe:无法打开图像 2,2':没有这样的文件或目录@ error/blob.c/OpenBlob/2641.\ r \ nconvert.exe:没有此图像格式的解码委托 2,2'@ error/constitute.c/ReadImage/550.\ r \ nconvert.exe:无法打开图像<代码> 0,0':没有这样的文件或目录@ error/blob.c/OpenBlob/2641.\ r \ nconvert.exe:此图像格式没有解码委托 0,0'@ error/constitute.c/ReadImage/550.\ r \ nconvert.exe:无法打开图像 2,198':没有此类文件或目录@ error/blob.c/OpenBlob/2641.\ r \ nconvert.exe:此图像格式没有解码委托 2,198'@ error/constitute.c/ReadImage/550.\ r \ nconvert.exe:无法打开图像 0,200':否这样的文件或目录@ error/blob.c/OpenBlob/2641.\ r \ nconvert.exe:此图像格式没有解码委托 0,200'@ error/constitute.c/ReadImage/550.\ r \ nconvert.exe:无法打开即时消息年龄 198,198':没有这样的文件或目录@ error/blob.c/OpenBlob/2641.\ r \ nconvert.exe:没有此图像格式的解码委托 198,198'@ error/constitute.c/ReadImage/550.\ r \ nconvert.exe:无法打开图像 200,200':没有这样的文件或目录@ error/blob.c/OpenBlob/2641.\ r \ nconvert.exe:没有为此图像的解码委托格式 200,200'@ error/constitute.c/ReadImage/550.\ r \ nconvert.exe:无法打开图像 198,2':无此类文件或目录@ error/blob.c/OpenBlob/2641.\r\nconvert.exe:此图像格式没有解码委托 198,2'@ error/constitute.c/ReadImage/550.\ r \ nconvert.exe:无法打开图像200,0'':没有这样的文件或目录@ error/blob.c/OpenBlob/2641.\ r \ nconvert.exe:没有此图像格式的解码委托 200,0''@错误/组成.c/ReadImage/550.\ r \ n"

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

推荐答案

'2,2 0,0 2,198 0,200 198,198 200,200 198,2 200,0'周围的单引号更改为转义双精度引号.在第一个引号之后也要立即删除多余的空格:

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

这篇关于从.Net调用Image Magick命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆