I\'m using a neat little php script to resize my images to fit in a 300x300 pixel square, while keeping the aspect ratio. I got the script from here.
Here is the whole s
Add fitToSquare function to SimpleImage class, this functions calculate the x and y coordinates of the source image, then crop as square. I haven't test my function:) But it seems ok.
function fitToSquare($width) {
$new_image = imagecreatetruecolor($width, $height);
$sourceX = 0;
$sourceY = 0;
if($this->getWidth() > $this->getHeight())
{
$sourceX = ($this->getWidth() - $this->getHeight()) / 2;
}
else
{
$sourceY = ($this->getHeight() - $this->getWidth()) / 2;
}
imagecopyresampled($new_image, $this->image, 0, 0, $sourceX, $sourceY, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}