title: Resize image and place in center of canvas
body: <p>I'm trying to do the following in iMagick and I can't get it to work:</p>
  
  <p>Check if image is over 390 pixels high, if it is then resize it to 390 pixels high, if it isn't keep the dimensions.</p>
  
  <p>Add a white canvas, 300px wide by 400px high and then place the image into the center of that.</p>
  
  <p>My Code is:</p>
  
  <pre><code>$im = new Imagick("test.jpg");
  $imageprops = $im-&gt;getImageGeometry();
  $width = $imageprops['width'];
  $height = $imageprops['height'];
  if($height &gt; '390'){
  $newHeight = 390;
  $newWidth = (390 / $height) * $width;
  }else{
  $newWidth = $imageprops['width'];
  $newHeight = $imageprops['height'];
  }
  
  $im-&gt;resizeImage($newWidth,$newHeight, Imagick::FILTER_LANCZOS, 0.9, true);
  
  $canvas = new Imagick();
  $canvas-&gt;newImage(300, 400, 'white', 'jpg');
  $canvas-&gt;compositeImage($im, Imagick::COMPOSITE_OVER, 100, 50);
  
  $canvas-&gt;writeImage( "test-1.jpg" );
  </code></pre>
  
  <p>When the images are produced the large ones are scaled to 388 pixels high for some reason and the small ones are left to their original dimensions.</p>
  
  <p>The placing on the canvas is always incorrect although does work on the large images with 100,50 added to the composite image.</p>
  
  <p>Most of the images are tall and thin however there are a few that are wider than they are tall.</p>
  
  <p>Any ideas where I am going wrong ?</p>
  
  <p>Thanks,</p>
  
  <p>Rick</p>