title: Reverse Image search (for image duplicates) on local computer
body: <p>I have a bunch of poor quality photos that I extracted from a pdf. Somebody I know has the good quality photo's somewhere on her computer(Mac), but it's my understanding that it will be difficult to find them.</p>
  <p>I would like to</p>
  <ul>
  <li>loop through each poor quality photo</li>
  <li>perform a reverse image search using each poor quality photo as the query image and using this persons computer as the database to search for the higher quality images</li>
  <li>and create a copy of each high quality image in one destination folder.</li>
  </ul>
  <p>Example pseudocode</p>
  <pre><code>for each image in poorQualityImages:
      search ./macComputer for a higherQualityImage of image
      copy higherQualityImage to ./higherQualityImages
  </code></pre>
  <p>I need to perform this action once.
  I am looking for a <strong>tool, github repo or library</strong> which can perform this functionality more so than a deep understanding of content based image retrieval.</p>
  <hr />
  <p>There's <a href="https://www.reddit.com/r/DataHoarder/comments/asr5iz/reverse_image_search_for_local_files/" rel="nofollow noreferrer">a post on reddit</a> where someone was trying to do something similar</p>
  <p><a href="https://github.com/knjcode/imgdupes" rel="nofollow noreferrer">imgdupes</a> is a program which seems like it almost achieves this, but I do not want to delete the duplicates, I want to copy the highest quality duplicate to a destination folder</p>
  <hr />
  <p><strong>Update</strong></p>
  <p>Emailed my previous image processing prof and he sent me this</p>
  <blockquote>
  <p>Off the top of my head, nothing out of the box.</p>
  <p>No guaranteed solution here, but you can narrow the search space.
  You’d need a little program that outputs the MSE or SSIM similarity
  index between two images, and then write another program or shell
  script that scans the hard drive and computes the MSE between each
  image on the hard drive and each query image, then check the images
  with the top X percent similarity score.</p>
  <p>Something like that.  Still not maybe guaranteed to find everything
  you want.  And if the low quality images are of different pixel
  dimensions than the high quality images, you’d have to do some image
  scaling to get the similarity index.   If the poor quality images have
  different aspect ratios, that’s even worse.</p>
  <p>So I think it’s not hard but not trivial either.  The degree of
  difficulty is partly dependent on the nature of the corruption in the
  low quality images.</p>
  </blockquote>
  <hr />
  <p><strong>UPDATE</strong></p>
  <p><a href="https://github.com/samgermain/Copy_Duplicate_Images" rel="nofollow noreferrer">Github project I wrote which achieves what I want</a></p>