mirror of
https://github.com/greenshot/greenshot.git
synced 2025-01-26 07:02:50 -08:00
4de75cdb69
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2149 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System;
|
|
using System.IO;
|
|
using Greenshot.Interop;
|
|
using GreenshotOCR;
|
|
|
|
namespace GreenshotOCRCommand {
|
|
public class Program {
|
|
private const string USAGE = "<-c> | <path to image.bmp> [language] [orientimage] [straightenImage]";
|
|
public static int Main(string[] args) {
|
|
// to test
|
|
//args = new string[] { @"C:\localdata\test.bmp"};
|
|
if (args.Length == 0) {
|
|
Console.WriteLine(USAGE);
|
|
return -1;
|
|
}
|
|
string filename = args[0];
|
|
ModiLanguage language = ModiLanguage.ENGLISH;
|
|
if (args.Length >= 2) {
|
|
language = (ModiLanguage)Enum.Parse(typeof(ModiLanguage), args[1]);
|
|
}
|
|
bool orientimage = true;
|
|
if (args.Length >= 3) {
|
|
orientimage = bool.Parse(args[2]);
|
|
}
|
|
bool straightenImage = true;
|
|
if (args.Length >= 4) {
|
|
straightenImage = bool.Parse(args[3]);
|
|
}
|
|
try {
|
|
if (File.Exists(filename) || "-c".Equals(filename)) {
|
|
using (ModiDocu modiDocument = COMWrapper.GetOrCreateInstance<ModiDocu>()) {
|
|
if (modiDocument == null) {
|
|
Console.WriteLine("MODI not installed");
|
|
return -2;
|
|
}
|
|
if ("-c".Equals(filename)) {
|
|
return 0;
|
|
}
|
|
modiDocument.Create(filename);
|
|
modiDocument.OCR(language, orientimage, straightenImage);
|
|
IImage modiImage = modiDocument.Images[0];
|
|
ILayout layout = modiImage.Layout;
|
|
Console.WriteLine(layout.Text);
|
|
modiDocument.Close(false);
|
|
return 0;
|
|
}
|
|
}
|
|
} catch (Exception ex) {
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
return -1;
|
|
}
|
|
}
|
|
}
|