Thanks StarLion.
My math teacher would definitely be a little disappointed with my algebra. Thanks for helping me understand that a bit better.
I now have figured out how to resize the image properly and save it to my database, etc. For some reason, however, I have not figured out how to make a thumbnail for the new re-sized 700 px image. I am properly thumbnailing for regular images perfectly, however. If anyone has a moment I could use an extra pair of eyes to help me see my mistake:
PHP Code:
list($width, $height) = getimagesize($file_tmp);
//calculate the image ratio
$imgratio=$width/$height;
if ($width>700) {
$newwidth = 700;
$newheight = $newwidth / $imgratio;
if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
$new_img = imagecreatefromjpeg($file_tmp);
}elseif($file_type == "image/pjpg" || $file_type == "image/jpg"){
$new_img = imagecreatefromjpeg($file_tmp);
}elseif($file_type == "image/x-png" || $file_type == "image/png"){
$new_img = imagecreatefrompng($file_tmp);
}elseif($file_type == "image/gif"){
$new_img = imagecreatefromgif($file_tmp);
}
$file_tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresized($file_tmp, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $wi dth, $height);
//finally, save the image
ImageJpeg ($file_tmp, $bigpath);
ImageDestroy ($file_tmp);
if ($imgratio>1){
$new2width = $ThumbWidth;
$new2height = $ThumbWidth/$imgratio;
//=================
}else{
$new2height = $ThumbWidth;
$new2width = $ThumbWidth*$imgratio;
//function for resize image.
$resized_img = imagecreatetruecolor($new2width,$n ew2height);
//the resizing is going on here!
imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $new2width, $new2height, $width, $height);
//finally, save the image
ImageJpeg ($resized_img, $thumbpath);
ImageDestroy ($resized_img);
ImageDestroy ($new_img);
}
Thanks everyone for the support in trying to figure out this issue. I really appreciate it.
Bookmarks