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))

   if img1 = img2 then
      response.write("Same Image")
   else
      response.write("Difference Image")
   end if
End Sub

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

Comments

Popular posts from this blog

การตั้งเวลาระหว่าง Server และ Client

วิธีตั้งค่า NTP บน Primary Domain Controller

Installation and Run Node.JS on IIS