Cropping photos

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);
  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.

this may help get you started …

Thanks. That looks as though it will get me going… G :slight_smile: