unistake Posted November 1, 2010 Share Posted November 1, 2010 Hi all, I have been looking at thumbnail scripts and they are all very advanced for what I want. I just want to take 3 uploadeed jpg images, save a copy in original format and save a copy in images/thumbs/ with a size of 200px x 133px. Could someone just show me who to do this? Thanks The script I have for uploading the actual image is: <?php $destination='aircraft/'.$reg."1.jpg"; $temp_file = $_FILES['image']['tmp_name']; move_uploaded_file($temp_file,$destination); $destination2='aircraft/'.$reg."2.jpg"; $temp_file2 = $_FILES['image2']['tmp_name']; move_uploaded_file($temp_file2,$destination2); $destination3='aircraft/'.$reg."3.jpg"; $temp_file3 = $_FILES['image3']['tmp_name']; move_uploaded_file($temp_file3,$destination3); ?> Quote Link to comment Share on other sites More sharing options...
litebearer Posted November 1, 2010 Share Posted November 1, 2010 Might look at ... http://www.nstoia.com/toh/imageresize.php Quote Link to comment Share on other sites More sharing options...
unistake Posted November 1, 2010 Author Share Posted November 1, 2010 Thanks for that. I have been trying to use it today but can not get it to work. The code I have is: Can anyone see anything wrong with it? I have put a note next the the part where I think I am going wrong. <?php $destination='aircraft/'.$reg."1.jpg"; $temp_file = $_FILES['image']['tmp_name']; move_uploaded_file($temp_file,$destination); $destination2='aircraft/'.$reg."2.jpg"; $temp_file2 = $_FILES['image2']['tmp_name']; move_uploaded_file($temp_file2,$destination2); $destination3='aircraft/'.$reg."3.jpg"; $temp_file3 = $_FILES['image3']['tmp_name']; move_uploaded_file($temp_file3,$destination3); // THUMBNAIL PROCESS $file = $_FILES['image']['name']; $save = $reg.'1.jpg'; $t_w = 200; $t_h = 133; $o_path = " "; // NOT SURE WHAT THIS COULD BE. $s_path = "aircraft/thumbs/"; 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; } ?> Quote Link to comment Share on other sites More sharing options...
sastro Posted November 1, 2010 Share Posted November 1, 2010 Try this <?php $destination='aircraft/'.$reg."1.jpg"; $temp_file = $_FILES['image']['tmp_name']; move_uploaded_file($temp_file,$destination); imgresize($destination); $destination2='aircraft/'.$reg."2.jpg"; $temp_file2 = $_FILES['image2']['tmp_name']; move_uploaded_file($temp_file2,$destination2); imgresize($destination); $destination3='aircraft/'.$reg."3.jpg"; $temp_file3 = $_FILES['image3']['tmp_name']; move_uploaded_file($temp_file3,$destination3); imgresize($destination); function imgresize($filename) { $source = imagecreatefromjpeg($filename);; $fullpath = $filename; list($width, $height) = getimagesize($filename); $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($thumb,$source,0,0,0,0,200, 133,$width,$height); imagejpeg($thumb, 'images/thumbs/'.basename($filename), 100); } ?> Quote Link to comment Share on other sites More sharing options...
unistake Posted November 1, 2010 Author Share Posted November 1, 2010 I cant see what the $filename is? Quote Link to comment Share on other sites More sharing options...
unistake Posted November 2, 2010 Author Share Posted November 2, 2010 Can anyone help? I just want to resize the image before I upload it. <?php $destination='aircraft/'.$reg."1.jpg"; $temp_file = $_FILES['image']['tmp_name']; move_uploaded_file($temp_file,$destination); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.