Out of curiosity, why would you ever want an image to stretch? o_O
Isn't the point of the crop functionality so that it would fill a specified height/width without having to stretch the image?
then the cropping process will be really complicated to explain
$source_img = @imagecreatefromjpeg($file); //Create a copy of our image for our thumbnails...
$new_w = $img_w;
$new_h = $img_h;
echo $new_w.",sdfsdfsdf";
$orig_w = $imageSourceWidth;
$orig_h = $imageSourceHeight;
$w_ratio = ($new_w / $orig_w);
$h_ratio = ($new_h / $orig_h);
if ($orig_w > $orig_h ) {//landscape
$crop_w = round($orig_w * $h_ratio);
$crop_h = $new_h;
$src_x = ceil( ( $orig_w - $orig_h ) / 2 );
$src_y = 0;
} elseif ($orig_w < $orig_h ) {//portrait
$crop_h = round($orig_h * $w_ratio);
$crop_w = $new_w;
$src_x = 0;
$src_y = ceil( ( $orig_h - $orig_w ) / 2 );
} else {//square
$crop_w = $new_w;
$crop_h = $new_h;
$src_x = 0;
$src_y = 0;
}
$dest_img = imagecreatetruecolor($new_w,$new_h);
// copy image
imagecopyresampled($dest_img, $source_img, 0 , 0 , $src_x, $src_y, $crop_w, $crop_h, $orig_w, $orig_h);
// save image depends from MIME type
if($imageData['mime'] == 'image/jpeg' || $imageData['mime'] == 'image/pjpeg' || $imageData['mime'] == 'image/jpg') imagejpeg($dest_img,$cache_dir.$filename, $config['img_quality']);
elseif($imageData['mime'] == 'image/gif') imagegif($dest_img, $cache_dir.$filename);
else imagepng($dest_img, $cache_dir.$filename);
// result