Jump to content
Sign in to follow this  
AARRGGHHH

Compare 2 Images to See if Identical - Using Base64

Recommended Posts


 

I'm trying to use Base64 to compare two images to see if they are identical. 

The images are accessed using: 

var thumb5Original = ""; 
var thumb5Edited = ""; 

thumb5Original = canvas5.toDataURL('image/png');
thumb5Edited = canvas5.toDataURL('image/png');

  I then check them using this: 

if (thumb5Original.toString() == thumb5Edited.toString()) document.getElementById('tHeader5').innerHTML = "Original Image"; 
if (thumb5Original.toString() != thumb5Edited.toString()) document.getElementById('tHeader5').innerHTML = "Edited Image"; 

The problem is, I'm getting "Edited Image" even when the images are identical.  Is there an error in the way I'm comparing the images? 

Thank you  
 

Share this post


Link to post
Share on other sites

I would print the values that you're comparing to see how different they are.  If they are completely different then I would suggest that the data URL is not a way to compare an image.  If they are only slightly different then that may be caused by a minor change you overlooked.

Share this post


Link to post
Share on other sites

I just came back here to close this thread.  justsomeguy, you were right on the money.  I used document.write() to print the values to screen, the printed values showed only minor differences, they were due to a minor change I had forgotten about. 

One thing I did learn from this is that canvas.toDataURL() actually does work quite well for determining whether 2 images are duplicates.   

justsomeguy, thank you very much for your time. 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...