在 IronOCR 中保存具有不同处理效果的图像

This article was translated from English: Does it need improvement?
Translated
View the article in English

如何保存应用了不同图像处理/图像滤镜的图像?

应用以下简单代码示例:

// Create a new instance of OcrInput from a text box input for file path.
OcrInput input = new OcrInput(browsFile_txt.Text);

// Apply a grayscale filter to the image.
input.ToGrayScale();

// Iterate through each page in the OcrInput object.
foreach (var p in input.Pages)
{
    // Save each processed page as an image with a unique timestamped filename.
    p.SaveAsImage($"{outputPath}\\{DateTime.Now.ToString("yyyyMMddHHmmss")}.png");
}
// Create a new instance of OcrInput from a text box input for file path.
OcrInput input = new OcrInput(browsFile_txt.Text);

// Apply a grayscale filter to the image.
input.ToGrayScale();

// Iterate through each page in the OcrInput object.
foreach (var p in input.Pages)
{
    // Save each processed page as an image with a unique timestamped filename.
    p.SaveAsImage($"{outputPath}\\{DateTime.Now.ToString("yyyyMMddHHmmss")}.png");
}
' Create a new instance of OcrInput from a text box input for file path.
Dim input As New OcrInput(browsFile_txt.Text)

' Apply a grayscale filter to the image.
input.ToGrayScale()

' Iterate through each page in the OcrInput object.
For Each p In input.Pages
	' Save each processed page as an image with a unique timestamped filename.
	p.SaveAsImage($"{outputPath}\{DateTime.Now.ToString("yyyyMMddHHmmss")}.png")
Next p
$vbLabelText   $csharpLabel

有关 IronOCR 中可用的图像优化过滤器的完整列表,请参阅IronOCR 图像过滤器

MSDN 风格的类文档 - OcrInput 方法

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 5,167,857 | Version: 2025.11 刚刚发布