400) { // MAKE THE HIGHT 375. $dest_height_fixed="385"; // Destination Height / $tn_size_height (Fixed) } else { // IF IT IS NOT BIGGER THAN 375. $dest_height_fixed="$src_height"; // Destination Height / $tn_size_height (Fixed) } } else { // IF WIDTH IS BIGGER THAN 500. $dest_width="400"; // Destination Width /$tn_size_width $dest_height_fixed="350"; // Destination Height / $tn_size_height (Fixed) } // OUT-PUT IMAGE DIMENTIONS. $dest_height= ($src_height * $dest_width) / $src_width; // (Aspect Ratio Variable Height // KEEP THE IMAGE AT THE RIGHT ASPECT. if ($dest_height>$dest_height_fixed) { // STUFF THAT WORKS. $dest_height = $dest_height_fixed; $dest_width = ($src_width * $dest_height) / $src_height; } $dest_file = SITE_PATH."/".UPLOAD_DIR."/magazine/".$filename; //Destination Image File $quality = "70"; // JPEG Image Quality (0-95 Higher Value == Better) // TIME TO PROCESS AND CREATE THE OUTPUT IMAGE $src_img = imagecreatefromjpeg($src_img); $dst_img = imagecreatetruecolor($dest_width,$dest_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); imageinterlace($dst_img, 1); $white = ImageColorAllocate($dst_img, 255, 255, 255); // MAKE SOME SIZE CORRECTIONS FOR THE AUTO BOARDER FEATURE. $dest_width = $dest_width-1; //Drop width by 1 to allow for the border $dest_height = $dest_height-1; // Same with Height imagerectangle ($dst_img, 0, 0, $dest_width, $dest_height, $white); // Write the Border ;-)s imagejpeg($dst_img, $dest_file, $quality); // DISTROY THE UPLOADED IMAGE AND TEMP IMAGE. imagedestroy($src_img); } // DID THE IMAGE GET UPLOADED? if (file_exists($dest_file)) { // ADD THE NEW IMAGE TO THE DATABASE. mysql_query("INSERT INTO magazine_img SET magImgActive = '1', magImgItem = '".$_POST['formId2']."', magImgByLine = '".$_POST['formCredit']."', magImgComment = '".$_POST['formComment']."', magImgFile = '".$filename."'") OR DIE (mysql_error()); $error = "0"; } else { // DON"T DO ANYTHING. $error = "1"; } } } // UPLOAD PHOTO. ?>