Compare Image from file
Imports System.IO
Imports System.Drawing
Dim img As Image
Dim img1,img2 as String
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
img = Image.FromFile("C:\Img1.jpg")
img1 = Convert.ToBase64String(imageToByteArray(img))
img = Image.FromFile("C:\Img2.jpg")
img2 = Convert.ToBase64String(imageToByteArray(img))
Public Function imageToByteArray(ByVal imageIn As System.Drawing.Image) As Byte()
Dim ms As MemoryStream = New MemoryStream()
imageIn.Save(ms, Imaging.ImageFormat.Jpeg)
Return ms.ToArray()
End Function
Imports System.Drawing
Dim img As Image
Dim img1,img2 as String
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
img = Image.FromFile("C:\Img1.jpg")
img1 = Convert.ToBase64String(imageToByteArray(img))
img = Image.FromFile("C:\Img2.jpg")
img2 = Convert.ToBase64String(imageToByteArray(img))
if img1 = img2 then
response.write("Same Image")
else
response.write("Difference Image")
end if
End SubPublic Function imageToByteArray(ByVal imageIn As System.Drawing.Image) As Byte()
Dim ms As MemoryStream = New MemoryStream()
imageIn.Save(ms, Imaging.ImageFormat.Jpeg)
Return ms.ToArray()
End Function
Comments
Post a Comment