title: How to scale-and-crop with imagemagick convert?
body: <p>Given the following PHP code:</p>
  
  <pre><code>function image_scale_and_crop(stdClass $image, $width, $height) {
    $scale = max($width / $image-&gt;info['width'], $height / $image-&gt;info['height']);
    $x = ($image-&gt;info['width'] * $scale - $width) / 2;
    $y = ($image-&gt;info['height'] * $scale - $height) / 2;
  
    if (image_resize($image, $image-&gt;info['width'] * $scale, $image-&gt;info['height'] * $scale)) {
      return image_crop($image, $x, $y, $width, $height);
    }
  }
  </code></pre>
  
  <p>To put it in English, first we do a resize keeping the aspect ratio so that the smaller edge of the image becomes the required size then the resulting image is cropped along the longer edge to <code>$width X $height</code> with equal amounts cut on each side (the smaller side won't need cropping).</p>
  
  <p>Is it possible to do this in a single <code>convert</code> command?</p>