-install package related .tif using nuget
PM> Install-Package BitMiracle.LibTiff.NET
Imports BitMiracle.LibTiff.Classic
Public Shared Function CheckCorruptedTiff(ByVal path As String) As Boolean
Dim result As Boolean = False
Using image As Tiff = Tiff.Open(path, "r")
If image Is Nothing Then
result = True
End If
Dim numberOfDirectories As Integer = image.NumberOfDirectories()
For i As Integer = 0 To numberOfDirectories - 1
image.SetDirectory(CShort(i))
Dim width As Integer = image.GetField(TiffTag.IMAGEWIDTH)(0).ToInt()
Dim height As Integer = image.GetField(TiffTag.IMAGELENGTH)(0).ToInt()
Dim imageSize As Integer = height * width
Dim raster As Integer() = New Integer(imageSize) {}
If Not image.ReadRGBAImage(width, height, raster, True) Then
result = False
End If
Next
End Using
Return result
End Function
PM> Install-Package BitMiracle.LibTiff.NET
Imports BitMiracle.LibTiff.Classic
Public Shared Function CheckCorruptedTiff(ByVal path As String) As Boolean
Dim result As Boolean = False
Using image As Tiff = Tiff.Open(path, "r")
If image Is Nothing Then
result = True
End If
Dim numberOfDirectories As Integer = image.NumberOfDirectories()
For i As Integer = 0 To numberOfDirectories - 1
image.SetDirectory(CShort(i))
Dim width As Integer = image.GetField(TiffTag.IMAGEWIDTH)(0).ToInt()
Dim height As Integer = image.GetField(TiffTag.IMAGELENGTH)(0).ToInt()
Dim imageSize As Integer = height * width
Dim raster As Integer() = New Integer(imageSize) {}
If Not image.ReadRGBAImage(width, height, raster, True) Then
result = False
End If
Next
End Using
Return result
End Function
No comments:
Post a Comment