Long ago I created a small library for resizing images using imagemagick through system(...)
because I did not feel that the build-in imagemagick functions for PHP
I tell one suggestion you can try it,
I saw the Image link I think the conditions are not checked correctly.
you have checked condition [(width/height) > (maxWidth/maxHeight)] Instead of check
if(width == height) { } elseif(width > height) { } else(width < height){ }
Check this condition and according to this condition crop the image and resize.
Thank you
The solution was the following:
if ($width/$height > $this->maxWidth/$this->maxHeight) {
// then resize to the new height...
$command .= ' -resize "x'.$this->maxHeight.'"';
// ... and get the middle part of the new image
// what is the resized width?
$resized_w = ($this->maxHeight/$height) * $width;
// crop
$command .= ' -crop "'.$this->maxWidth.'x'.$this->maxHeight.'+'.round(($resized_w - $this->maxWidth)/2).'+0" +repage';
} else {
$command .= ' -resize "' . $this->maxWidth . 'x"';
$resized_h = ($this->maxWidth/$width) * $height;
// crop
$command .= ' -crop "'.$this->maxWidth.'x'.$this->maxHeight.
'+0+'.round(($resized_h - $this->maxHeight)/2).'" +repage';
}