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
I fixed the function posted by @adenizc and created a pull-request to the SimpleImage library. Here is the function:
/**
* Square crop
*
* This function crops the image to fit the given size which is both the width and the height
*
* @param int $size
*
* @return SimpleImage
*/
function square($size) {
$new = imagecreatetruecolor($size, $size);
$sourceX = 0;
$sourceY = 0;
if($this->width > $this->height) {
$this->fit_to_height($size);
$sourceX = ($this->width - $size) / 2;
}
else {
$this->fit_to_width($size);
$sourceY = ($this->height - $size) / 2;
}
imagealphablending($new, false);
imagesavealpha($new, true);
imagecopy($new, $this->image, 0, 0, $sourceX, $sourceY, $size, $size);
$this->image = $new;
return $this;
}