title: Imagick resize image with padding
body: <p>I have wrote function which should resize given image into box and add white padding around the image from top and bottom</p>
  
  <pre><code> public function resizeToBox($MAX_SIZE, $path) {
  
  
        $im = new \Imagick($this-&gt;fullPath);
  
        $width=$this-&gt;width;
        $height=$this-&gt;height;
        if($width &gt; $MAX_SIZE || $height &gt; $MAX_SIZE) {
         $aspect = $width / $height;
         if($width &gt; $height) {
          $width = $MAX_SIZE;
          $height = intval($MAX_SIZE / $aspect);
         } else {
          $height = $MAX_SIZE;
          $width = intval($MAX_SIZE * $aspect);
         }
        }
        $offsetX =  intval(($MAX_SIZE - $width)/2);
        $offsetY =  intval(($MAX_SIZE - $height)/2);
  
  
        $im-&gt;resizeImage($width, $height, \imagick::FILTER_LANCZOS, 0.9, true);
        $im-&gt;cropImage ($MAX_SIZE, $MAX_SIZE, 0,0);
        $im-&gt;setGravity(\imagick::GRAVITY_CENTER);
        $im-&gt;setImageBackgroundColor('white');
        $im-&gt;extentImage($MAX_SIZE,$MAX_SIZE,$offsetX ,$offsetY);
  
        $resizePath =  $path. "/" . $this-&gt;name . "." . $this-&gt;imageMime;
        $im-&gt;writeImage( $resizePath);
  
  
     }
  </code></pre>
  
  <p>when I do </p>
  
  <pre><code>$im-&gt;extentImage($MAX_SIZE,$MAX_SIZE,0 , 0); 
  </code></pre>
  
  <p>my image stays on the top left corner 
  and when I do </p>
  
  <pre><code>$im-&gt;extentImage($MAX_SIZE,$MAX_SIZE,$offsetX ,$offsetY); 
  </code></pre>
  
  <p>the top of the images gets cut, not sure what I am doing wrong</p>