Hey guys, I have a script that uploads images and resizes them according to aspect ratio. The image is resized to 200px wide and 200px high. The script works great for the most part, but I've noticed that if I put in an image over 2000px--even just a small, 60K image--the image won't resize. My case parameters don't specify any specific thing for it--for some reason it just does it. Tried changing memory limit, but really don't think that has anything to do with it? Here's my code below. Sorry if it's not the best, I'm still an amateur. Any help with this would help me tremendously! Thanks.
function ResizeImage($new_filename)
{
$objclsCheckImage = new clsCheckImage();
list($width, $height, $type, $attr) = getimagesize($new_filename);
//WE DIVIDE THE ORIGINAL WIDTH BY 100 TO GET PERCENTAGE TO SCALE
$new_width_perc = 200 / $width;
//WE DIVIDE THE ORIGINAL HEIGHT BY 100 TO GET PERCENTAGE TO SCALE
$new_height_perc = 200 / $height;
//CALCULATE NEW WIDTH
$new_width = $width * $new_width_perc;
//CALCULATE NEW HEIGHT
$new_height = $height * $new_height_perc;
//DETERMINE ASPECT RATIO
$asp_ratio = $width / $height;
//IF ASPECT RATIO IS LESS THAN 1, THEN WE NEED TO DETERMINE WIDTH
//THAT WILL MATCH UP WITH ASPECT RATIO
if($new_width/$new_height > $asp_ratio)
{
$new_width = $new_height * $asp_ratio;
}
//OTHERWISE, WE NEED TO DETERMINE HEIGHT THAT WILL MATCH UP WITH
//ASPECT RATIO
else
{
$new_height = $new_width / $asp_ratio;
}
//CASE
switch($height)
{
//IF HEIGHT IS GREATER THAN 200, RESIZE APPROPRIATELY
case $height > 200:
$image = imagecreatefromjpeg($new_filename);
$resized_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($resized_image,$image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($resized_image, $new_filename);
break;
case $width > 200:
$image = imagecreatefromjpeg($new_filename);
$resized_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($resized_image,$image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($resized_image, $new_filename);
break;
}
$objclsCheckImage->DisplayResults($new_filename);
}//END OF FUNCTION