cooldude832 Posted October 22, 2007 Share Posted October 22, 2007 I'm trying to upload and resize an image, and for some reason its only copy part of the image this is what i'm using <?php $img_types = array("image/jpg", "image/pjpg", "image/jpeg", "image/pjpeg", "image/png", "image/gif"); $new_path = ROOT."graphics/counselor/".$_SESSION['FacID'].".jpg"; if (in_array($_FILES['image']['type'], $img_types) && $to_q == 1){ if(copy ($_FILES['image']['tmp_name'], $new_path)){ list($width, $height) = getimagesize($new_path); $target = 150; if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } //gets the new value and applies the percentage, then rounds the value $width = round($width * $percentage); $height = round($height * $percentage); $imgdata = getimagesize($new_path); $thumb = ImageCreateTrueColor(150, 150); $source = imagecreatefromjpeg($new_path); imagecopyresized($thumb, $source, 0, 0, 0, 0, 150, 150, $width, $height); imagejpeg($thumb,$new_path,100); $q = "Update `".F_TABLE."` Set Image='1' Where FacID ='".$_SESSION['FacID']."'"; $r = mysql_query($q) or die(mysql_error()); } else{ $errors[] = "The Image could not be uploaded please try again<br />".$_FILES['image']['tmp_name']."<br />".$new_path; } } else{ if(!empty($_FILES['image']['tmp_name'])){ $errors[] = "Invalid File Type must be a jpeg"; } ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted October 22, 2007 Author Share Posted October 22, 2007 figured it out, but know its sorta a blur image any ideas? <?php if (in_array($_FILES['image']['type'], $img_types) && $to_q == 1){ if(copy ($_FILES['image']['tmp_name'], $new_path)){ list($width, $height) = getimagesize($new_path); $target = 150; if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } //gets the new value and applies the percentage, then rounds the value $width1 = round($width * $percentage); $height1 = round($height * $percentage); $imgdata = getimagesize($new_path); $thumb = ImageCreateTrueColor($width1, $height1); $source = imagecreatefromjpeg($new_path); imagecopyresized($thumb, $source, 0, 0, 0, 0, $width1, $height1, $width, $height); imagejpeg($thumb,$new_path,100); $q = "Update `".F_TABLE."` Set Image='1' Where FacID ='".$_SESSION['FacID']."'"; $r = mysql_query($q) or die(mysql_error()); ?> 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.