I figured out how to do it with a little help from a script I found online. I'm going to post the code so that if another person runs into the problem they'll find the solution here.
$function_suffix = $gd_function_suffix[$filetype];
// Instead of finding out which output function to use by testing the extension,
// just use the extension to create the function
$function_to_read = "imagecreatefrom".$function_suffix;
$function_to_write = "image".$function_suffix;
/* Add this check
* check to see if the image is great then 768 pixels wide and tall
* if the picture is wider or tall then the make lenght resize the picture and copy it to the server
* else copy it to the server
*/
$origimage = $function_to_read($photos_uploaded['tmp_name'][$counter]);
// Create the main image
if($origimage)
{
$origwidth = imagesx($origimage);
$origheight = imagesy($origimage);
if($origwidth > $maxSideLength) {
$width = $maxSideLength;
$height= (int)($maxSideLength * ($origheight / $origwidth));
// Create an image template based on the file's extension
if($function_suffix == $photo_types['image/gif']) {
$tmpimage = imagecreate($width, $height);
}
else {
$tmpimage = imagecreatetruecolor( $width, $height );
}
imagecopyresized( $tmpimage, $origimage, 0, 0, 0, 0, $width, $height, $origwidth, $origheight );
// Save the cropped image to the server
$function_to_write( $tmpimage, $images_dir."/".$photo_category['category_name']."/".$filename );
imagedestroy( $tmpimage );
echo "cropping\n";
}
elseif($origheight > $maxSideLength) {
$width = (int)($maxSideLength * ($origwidth / $origheight));
$height = maxSideLength;
// Create an image template based on the file's extension
if($function_suffix == $photo_types['image/gif']) {
$tmpimage = imagecreate($width, $height);
}
else {
$tmpimage = imagecreatetruecolor( $width, $height );
}
imagecopyresized( $tmpimage, $origimage, 0, 0, 0, 0, $width, $height, $origwidth, $origheight );
// Save the cropped image to the server
$function_to_write( $tmpimage, $thumbs_dir."/".$photo_category['category_name']."/".$filename );
imagedestroy( $tmpimage );
echo "cropping\n";
}
else {
// Store the orignal file
echo "saving\n";
move_uploaded_file($photos_uploaded['tmp_name'][$counter], $images_dir."/".$photo_category['category_name']."/".$filename);
}
}