title: Compare two images with ImageMagick
body: <p>I am trying to take two images and compare them using ImageMagick. </p>
  
  <p>I want to find out if the images are close to the same and return a number to be stored in a variable in php and displayed in my browser screen.</p>
  
  <p>My hosting account is with bluehost and I have tested by resizing an image and ImageMagick is installed and running. The following code works here: <a href="http://zing-cards.com/imagetest2.php" rel="nofollow">http://zing-cards.com/imagetest2.php</a></p>
  
  <pre><code>&lt;?php
  $photo="/home/tcsdesig/public_html/zing/flower.jpg";
  $cmd = "/usr/bin/convert $photo -thumbnail 100x100 JPG:-";
  
  header("Content-type: image/jpeg");
  passthru($cmd, $retval);
  
  ?&gt;
  </code></pre>
  
  <p>I understand the the following command line code (according to this <a href="http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&amp;t=15767" rel="nofollow">post</a>) is supposed to get the results in a number format:</p>
  
  <pre><code>compare -metric RMSE first.png second.png NULL:
  </code></pre>
  
  <p>Here is my code so far:</p>
  
  <pre><code>&lt;?php
  $photoPath1="/home/*username*/public_html/flower.jpg";
  $photoPath2="/home/*username*/public_html/flower1.jpg";
  
  $cmd = "/usr/bin/compare -metric RMSE $photoPath1 $photoPath2 NULL:";
  exec($cmd);
  ?&gt;
  </code></pre>
  
  <p>How do I make this value show in my browser?</p>
  
  <p>Other than the above code I have tried:</p>
  
  <pre><code>$result = exec($cmd);
  echo $result;
  </code></pre>
  
  <p>From what I understand this should display a low number (since the images are equal) and if I use completely different images they should display a high number but I don't get any results.</p>