I have a script that resizes photos. The code that does the work is basically:
$imageSrc = imagecreatefromjpeg($file);
$imageDest = imagecreatetruecolor($newWidth, $newHeight);
if ( imagecopyresampled($imageDest, $imageSrc, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height) ) {
imagejpeg($imageDest, $fileDest, $quality);
imagedestroy($imageSrc);
imagedestroy($imageDest);
return true;
}
However, I want to be able to crop them as well, to make square versions. Any ideas please? I’m on PHP 5.4. If I just use the same values for $height and $width the photo is just squished.