Hi,
I have the following code that worked in Aspose.OCR for .NET (Product Version: 2016.06.10) after updating to the latest version (22.8.0) it no longer works. The purpose of the function is to deskew an image. I’ve tried a few different things refactoring the code but have not been able to figure it out. How can we deskew images and save in the same formats as shown in the code below?
Private Shared Function AutoDeskewImage(ByVal ExistingImage As Image, ByVal Save As Boean) As Image
Dim engine As OmrEngine = Nothing
Dim omrImg As OmrImage = Nothing
Dim ms As MemoryStream = Nothing
Dim degree As Integer
Try
'Load omr image from aspose image
ms = New MemoryStream()
ExistingImage.Save(ms)
ms.Seek(0, System.IO.SeekOrigin.Begin)
omrImg = Aspose.OMR.OmrImage.Load(ms)
ms.Flush()
'Use empty template or load any existing template
engine = New OmrEngine(New OmrTemplate())
'Get skew degree of the image
degree = engine.GetSkewDegree(omrImg)
'Rotate image to correct skew
engine.RotateImage(omrImg, degree)
'copies the omr image to existing image with tiff format
omrImg.AsBitmap().Save(ms, System.Drawing.Imaging.ImageFormat.Tiff)
ms.Seek(0, System.IO.SeekOrigin.Begin)
ExistingImage = ImageCtm.Load(ms)
ExistingImage.Save()
ms.Flush()
If Save Then
Image = ExistingImage
End If
Return ExistingImage
Catch ex As System.Exception
Throw ex
Finally
If ms IsNot Nothing Then
ms.Dispose()
ms = Nothing
End If
End Try
End Function