Troubleshooting older version of System.Drawing
.NET 4.6.1 to .NET 4.8 project comes with built-in System.Drawing version 4.0.0. This version of System.Drawing is out of support and may contain vulnerable code.
Trying to instantiate OcrInput from System.Drawing.Image will throw "IronOcr.Exceptions.IronOcrProductException: 'Unable to parse Object [] as a valid image file.'. This due to IronOcr could not recognize System.Drawing.Image as valid input type." exception
Trying to specify Image input type like OcrInput(Image: image) will throw "cannot convert from System.Drawing.Image to SixLabors.ImageSharp.Image" error
Possible solution
Update System.Drawing.Common to version 6.0.0 Older version of System.Drawing is out of support and may contain vulnerable code.
- Use SixLabors.ImageSharp version 2.1.3 OcrInput can be instantiated with SixLabors.ImageSharp.Image type.
var Ocr = new IronTesseract();
Image image = Image.Load("image.jpg");
using (var Input = new OcrInput(image))
{
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
var Ocr = new IronTesseract();
Image image = Image.Load("image.jpg");
using (var Input = new OcrInput(image))
{
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text);
}
Dim Ocr = New IronTesseract()
Dim image As Image = System.Drawing.Image.Load("image.jpg")
Using Input = New OcrInput(image)
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text)
End Using