title: Algorithm for sorting images by relevance
body: <p>I'm developing a feature on a forum site that will allow to include a link and other type of content on a post (for clarifying the question or answer).</p>
  
  <p>Related to the link feature implementation, I have several things to work on:</p>
  
  <ol>
  <li>Validate the URI entered (well formed, valid scheme, etc.)</li>
  <li>Validate that the remote resource exists</li>
  <li>Extract images from within the remote page</li>
  <li>Show to the user the set of images and let him choose one</li>
  </ol>
  
  <p><strong>Here comes the challenge</strong>. Previous to step 4, it would be great to sort this set of images in order of '<em>relevance</em>'. I know that it's a goal quite ambiguous :-) but I can explain what I've gone through with the results given in step 4 and you will know why I'm dealing with this solution.</p>
  
  <p>Many times, I get this kind of things into the set of images:</p>
  
  <ul>
  <li>Images used for the layout of the page (tiny and useless)</li>
  <li>Banners and ads</li>
  <li>Pseudo-duplication of images (original and resized one)</li>
  <li>Anarchical order of the set (logo on last position, etc.)</li>
  </ul>
  
  <p>I decide to clean up this mess removing tiny images and sorting them by size, but I know that will be far away from a good solution.</p>
  
  <p>Any ideas on that???</p>
  
  <p>Thank you very much!</p>