internal static string MagicIMG(string MagicPATH, string IMGPath, string ResultName, bool Multi) { int intWidth; int intHeight; Image pic = Image.FromFile(IMGPath); int x = pic.Width; int y = pic.Height; if (!Multi) { intWidth = pic.Width - pic.Width / 30; //长度像素值 intHeight = pic.Height - pic.Width / 30; //高度像素值} CallCommand.CallCammand(MagicPATH + "\\convert.exe", " -level 100%,0% -despeckle -crop " + intWidth + "x" + intHeight + "+" + pic.Width / 60 + "+" + pic.Width / 60 + " -resize " + x * 3 + "x" + y * 3 + " \"" + IMGPath + "\" " + ResultName + ".tiff"); } else { intWidth = pic.Width; //长度像素值 intHeight = pic.Height; //高度像素值} CallCommand.CallCammand(MagicPATH + "\\convert.exe", " -level 100%,0% -despeckle" + " -resize " + x * 3 + "x" + y * 3 + " \"" + IMGPath + "\" " + ResultName + ".tiff"); } return(ResultName + ".tiff"); }
internal static void CutImage(string MagicPATH, string IMGPath) { Image pic = Image.FromFile(IMGPath); int intWidth = pic.Width; int intHeight = pic.Height / 2; CallCommand.CallCammand(MagicPATH + "\\convert.exe", " \"" + IMGPath + "\" " + " -crop " + intWidth + "x" + intHeight + "+" + " dest.bmp"); }
internal static string AnalyzePicture(string ORCPath, string IMGPath, string APPPath, bool isDouble) { if (!isDouble) { CallCommand.CallCammand(ORCPath + "\\tesseract.exe", " -l eng -psm 7 \"" + IMGPath + "\" out"); } else { CallCommand.CallCammand(ORCPath + "\\tesseract.exe", " -l eng -psm 6 \"" + IMGPath + "\" out"); } //他会在ORC目录下生成 out.txt 下面就读这个文件就好了 while (true) { if (File.Exists(APPPath + "\\out.txt")) { return(File.ReadAllText(APPPath + "\\out.txt")); } } }
internal static void ConvertImg(string MagicPATH, string IMGPath, string Fname) { CallCommand.CallCammand(MagicPATH + "\\convert.exe", " \"" + IMGPath + "\" " + Fname + ".tiff"); }