I have C# program which compare 2 .jpg files,
I was using this function I found in the internet to do that, it’s working well but it’s very slow ( takes more than a second to compare )
public static bool ImageCompareString(Bitmap firstImage, Bitmap secondImage)
{
MemoryStream ms = new MemoryStream();
firstImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
String firstBitmap = Convert.ToBase64String(ms.ToArray());
ms.Position = 0;
secondImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
String secondBitmap = Convert.ToBase64String(ms.ToArray());
if (firstBitmap.Equals(secondBitmap))
{
return true;
}
else
{
return false;
}
}
Now I was wondering why not use checksum which is faster to do the compare ?
Does the results byte to byte comparison are more accurate ?
The reason I need to compare jpg file:
On my PC I have thousands of jpg files taken from my Camera and Smartphone but many of them are duplicated (Identical pictures with same name exists on different sub folders and some having the same name but are not same pictures)
I want to move all the unique pictures to a new folder and delete those that are duplicate so in case I have 2 pictures that have the same name I need to compare them.