如何将.tif文件转换为.txt文件 [英] How to convert .tif file to .txt file

查看:371
本文介绍了如何将.tif文件转换为.txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将.tif文件转换为Windows应用程序中的.txt文件(.Net(C#))

解决方案

Path.ChangeExtension 可以用来改变Path字符串的扩展名



EX:

字符串filePath =E:\\WindowsPractice \\\ \\ Class1.tif;

Path.ChangeExtension(filePath,。txt);





要在物理上更改文件的扩展名:


File.Move(filePath,Path.ChangeExtension(filePath,。txt));


Hello Dheerendra,



这是一个基于ASPOSE OCR SDK的小片段。

< pre lang =c#> // 创建OcrEngine实例并分配图像,语言和图像配置
OcrEngine ocr = new OcrEngine();
ocr.Image = ImageStream.FromFile( 你的图像路径);
ocr.Languages.AddLanguage(Language.Load( english));
ocr.Config.NeedRotationCorrection = chkRotation.Checked;
ocr.Config.UseDefaultDictionaries = true ;
// 设置资源文件名并提取OCR文本
使用(ocr.Resource = new FileStream(resourceFileName,FileMode.Open)){
if (ocr.Process()){
strText = ocr.Text.ToString();
}
}





在ASPOSE网站上可以找到更完整的样本[^ 。有一个免费软件包装[ ^ ]可用于Tesseract [^ ] OCR图书馆。另一种方法是使用MODI,它是Microsoft Office的一部分。



问候,


How to Convert .tif file to .txt file in Windows application(.Net(C#))

解决方案

Path.ChangeExtension can be used to change the extention of Path string

EX:
String filePath = "E:\\WindowsPractice\\Class1.tif";
Path.ChangeExtension(filePath, ".txt");


To change the extention of the file physically:

File.Move(filePath, Path.ChangeExtension(filePath, ".txt"));


Hello Dheerendra,

Here is a small snippet based on ASPOSE OCR SDK.

//Create OcrEngine instance and assign image, language and image configuration
OcrEngine ocr = new OcrEngine();
ocr.Image = ImageStream.FromFile("YOUR IMAGE PATH");
ocr.Languages.AddLanguage(Language.Load("english"));
ocr.Config.NeedRotationCorrection = chkRotation.Checked;
ocr.Config.UseDefaultDictionaries = true;
//Set resource file name and extract OCR text
using (ocr.Resource = new FileStream(resourceFileName, FileMode.Open)) {
    if (ocr.Process()) {
        strText = ocr.Text.ToString();
    }
}



A more complete sample can be found on ASPOSE web site[^]. There is a freeware wrapper[^] available for Tesseract[^] OCR Library as well. Another alternative is to use MODI which is part of Microsoft Office.

Regards,


这篇关于如何将.tif文件转换为.txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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