Resizing Images

Hey guys, recently fixed an issue with my resizing script, but now i’ve added in another part to resize the image again, but since adding in /* Thumbnail Image */ part, it isn’t showing in the folders that it has resized the image at all… Hope you understand what I mean lol :stuck_out_tongue:

Here’s the code:

<?php
function Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path) { 
	$s_path = trim($s_path); 
	$o_path = trim($o_path); 
	$save = $s_path . $save; 
	$file = $o_path . $file; 
	$ext = strtolower(end(explode('.',$save))); 
	list($width, $height) = getimagesize($file) ; 
	if(($width>$t_w) OR ($height>$t_h)) { 
		$r1 = $t_w/$width; 
		$r2 = $t_h/$height; 
		if($r1<$r2) { 
			$size = $t_w/$width; 
		}else{ 
			$size = $t_h/$height; 
		} 
	}else{ 
		$size=1; 
	} 
	$modwidth = $width * $size; 
	$modheight = $height * $size; 
	$tn = imagecreatetruecolor($modwidth, $modheight) ; 
	switch ($ext) { 
		case 'jpg': 
		case 'jpeg': 
			$image = imagecreatefromjpeg($file) ; 
			break; 
		case 'gif': 
			$image = imagecreatefromgif($file) ; 
			break; 
		case 'png': 
			$image = imagecreatefrompng($file) ; 
			break; 
	} 
	imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 
	imagejpeg($tn, $save, 100) ; 
	return; 
}

$file = $newfile;
$filename = $dir . $file;

/* Profile Picture */
$save = $filename;
$t_w = 380;
$t_h = 137;
$o_path = "upload/"; 
$s_path = "upload/newfile/";

/* Thumbnail Picture */
$t_w = 50;
$t_h = 50;
$o_path = "upload/newfile/"; 
$s_path = "upload/thumb/";

Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path);
?>

Looks like it supposed to be this (you are missing call to your resize function for Profile picture):
[php]/* Profile Picture */
$save = $filename;
$t_w = 380;
$t_h = 137;
$o_path = “upload/”;
$s_path = “upload/newfile/”;

Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path); // <----- here

/* Thumbnail Picture */
$t_w = 50;
$t_h = 50;
$o_path = “upload/newfile/”;
$s_path = “upload/thumb/”;

Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path);[/php]

Thanks man! :stuck_out_tongue:

Sorry for double post and also if this question has already been covered…

but…

When I submit my form with an apostrophe in the textarea it won’t submit, I don’t get an error message or anything it just doesn’t submit? Any ideas?

Do you mean it is not saving to database on submission, or some other processing - how it is “not submit”? If it is really not submit, maybe you have bugs in javascript validation of entered value? Otherwise, if form is submitting, check this setting in your php.ini magic_quotes_gpc - if it is On, it will automatically escape apostrophes with backslash.

Ye its not saving to the database :frowning:

Sponsor our Newsletter | Privacy Policy | Terms of Service