PHP resizing script will not shrink all the time?

jonathan95123

New member
i have been trying to figure out why this little code wont shrink pictures bigger than a certain dimension (2246 x 1494).


header('Content-type: image/jpeg');

// Get new sizes
list($width, $height) = getimagesize($uploadfile);
if ($width > 750 || $height > 750)
{
if ($width <= $height)
{
$percent = 750 / $height ;
}
else
{
$percent = 750 / $width ;
}
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($uploadfile);

// Resize
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb, $uploadfile , 85) ;

}



This problem has been bugging me for months and have not been able to find a solution. the picture file size is not a factor, just the dimensions of the picture. Appreciate the help guys.
 
Back
Top