Looks like I screwed up a couple things when stripping out the features you didn't need. This test worked fine for me. (Note that it's outputting the image directly, versus writing it to a file. See my first reply for the imagejpeg() syntax to write it to a file if that's what you need.)
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$imageFile = 'C:\Users\Public\Pictures\Sample Pictures\Penguins.jpg';
$newImage = myCrop($imageFile, 430, 430, $error);
if($newImage == false) {
die($error);
}
// this is directly displaying the image, change it to write to file if desired:
header('Content-Type: image/jpeg');
imagejpeg($newImage);
exit;
/**
* Resize image to specific dimension, cropping as needed
* @return resource Resized image resource, or boolean false on failure
* @param string $imgFile Path to image to be resized
* @param int $width
* @param int $height
* @param string $error Error message
*/
function myCrop($imgFile, $width=430, $height=430, &$error = null)
{
$attrs = @getimagesize($imgFile);
if($attrs == false) // or $attrs[2] != IMG_JPEG)
{
$error = "Uploaded image is not JPEG or is not readable by this page.";
return false;
}
$src = imagecreatefromjpeg($imgFile);
if($src == false) {
$error = "Unable to load source image.";
return false;
}
$resized = imagecreatetruecolor($width, $height);
$result = imagecopyresampled($resized, $src, 0, 0, 0, 0, $width, $height, $width, $height);
if($result == false)
{
$error = "Error trying to resize and crop image.";
return false;
}
else
{
return $resized;
}
}