оразмеряване на снимки

lord_simeon

Registered
Здравейте вече имам код за качването на снимките сега ми трябва код който при качване на снимка да прави това :
1. Ако размерът на снимката е по-голям от 1024х768 да го смалява на толкова
2. Ако размерът на снимката е 300 кб да я прави 70% качество

ето и кода за качване на снимките :

Код:
/***************************************************************************
 * GET PICTURE DETAILS --->
 ***************************************************************************/

 $get_main_picture = mysql_query("SELECT * FROM pictures 
 WHERE picture_username='".$user_info['username']."' AND picture_type='1'");
								 
 if ( mysql_num_rows($get_main_picture) == 1 ){

 $got_main_picture = mysql_fetch_array($get_main_picture);

 $my_main_picture = 'include/images.inc.php?picture=../'.$got_main_picture['picture_path'];

 } else {

 $my_main_picture = 'themes/'.$site_theme.'/images/default_picture.gif';

 }
 
 ## DEFAULT PICTURE
 if (mysql_num_rows($get_main_picture)==0){

 $my_main_picture_status = $lang['picture_main_default'];
 
 }
 
 ## PICTURE PENDING
 else if ($got_main_picture['picture_status']==0){
 
 $my_main_picture_status = $lang['picture_pending'];
 
 }
 
 ## PICTURE APPROVED
 else if ($got_main_picture['picture_status']==1){
 
 $my_main_picture_status = $lang['picture_approved'];
 
 ## PICTURE DENIED
 } else {

 $my_main_picture_status = $lang['picture_denied'];

 }


 /***************************************************************************
 * UPDATE MAIN PICTURE --->
 ***************************************************************************/

 if (isset($_POST['update_main_picture'])){

 $check_exists = mysql_query("SELECT * FROM pictures 
 WHERE picture_username = '".$user_info['username']."' AND picture_type = '1'");

 //$ext = strstr($_FILES['main_picture']['name'],".");
 $ext = strchr($_FILES['main_picture']['name'],".");
 $temp_small = rand(2, 999999);
 $temp_number = rand(2, 999999999);
 $name = $_FILES['main_picture']['name'];
 $file = "pictures/".$temp_number."_".$temp_small.$ext;
 
 // CHECK IF AUTO-APPROVE IS ON
 if ($site_settings['approve_pictures'] == 'Yes'){
 
 $approval = '1';
 
 } else {
 
 $approval = '0';
 
 }

 if (($ext!= ".jpg") && ($ext!= ".gif") && ($ext!= ".jpeg") && ($ext!= ".JPG") && ($ext!= ".png")){

 header ('Location: my_pictures.php?action=error_type');
 
 } else if (mysql_num_rows($check_exists) == 1){
  
 $checked_exists = mysql_fetch_array($check_exists);
							  
 @unlink($checked_exists['picture_path']);

 if (copy($_FILES['main_picture']['tmp_name'], 'pictures/'.$temp_number.'_'.$temp_small.$ext)){

 mysql_query("UPDATE pictures 
			  SET picture_path='".$file."', 
			  picture_status='".$approval."' 
			  WHERE picture_username='".$user_info['username']."' 
			  AND picture_type='1'");

 mysql_query("UPDATE users 
			  SET profile_picture='0' 
			  WHERE username='".$user_info['username']."'");
			 
 header ('Location: my_pictures.php?action=uploaded_picture');

 }

 } else {

 if (copy($_FILES['main_picture']['tmp_name'], 'pictures/'.$temp_number.'_'.$temp_small.$ext)){

 mysql_query("INSERT INTO pictures 
		     (picture_username, picture_type, picture_path, picture_status) VALUES 
			 ('".$user_info['username']."', 
			 '1', '".$file."', '".$approval."')")or die(mysql_error());

 mysql_query("UPDATE users 
			  SET profile_picture = '".$approval."' 
			  WHERE username = '".$user_info['username']."'")or die(mysql_error());

 header ('Location: my_pictures.php?action=uploaded_picture');
 
 }
 }
 }

Кодът е от готова система :oops: дано да успеете да се справите с задачката
 
Някой ще помогне ли ??? :cry:
 

Back
Горе