Solarpitch Posted November 12, 2007 Share Posted November 12, 2007 Hey Guys, I am using the below script to upload and resize an image if needs be but in the process of trying to make it work, its gone very messy. What would be the optimal way to clean this script up? $image1 = $_FILES['image1']['tmp_name']; $max = 800; if($_FILES['image1']['tmp_name'] != ""){ list($width, $height, $type, $attr) = getimagesize($_FILES['image1']['tmp_name']); move_uploaded_file($_FILES['image1']['tmp_name'], $image1file); $copy1 = $image1; if(($width > $height) && ($width > $max)) { $height = (($height/$width) * $max); $width = $max; $resize = "true"; } else if (($height > $width) && ($height > $max)) { $width = (($width/$height) * $max); $height = $max; $resize = "true"; } if ($resize == "true") { $newwidth=700; $newheight=($height/$width)*560; $src = imagecreatefromjpeg($image1); $tmp=imagecreatetruecolor($tn_width,$tn_height); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $image1 = $folder.$timest."AA".$_FILES['image1']['name']; imagejpeg($tmp,$image1,100); imagedestroy($src); imagedestroy($tmp); } $destination_width = 160; $destination_height = 110; $imagecop1 = new hft_image($copy1); $sz=getimagesize($copy1); $imagecop1->resize($destination_width, $destination_height, '-'); $image1thumb = $folder.$timest."AA"."THUMB.jpg"; $imagecop1->output_resized($image1thumb, "JPEG"); } Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted November 12, 2007 Share Posted November 12, 2007 its got something to do with ImageCreateFrom???(); Function but im not sure on how to properly use it in this tpe of fashion. The PHP.net manual is great for these types of things 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.