title: PHP: if more than ..px resize to
body: <p>I want to do so if the image are over the dimensions 604x453, then resize it to 604x453.</p>
  
  <p>Ive made it this far:</p>
  
  <pre><code>    $org_name = stripslashes($_FILES[$upload_name]['name']);
      $file_size = $_FILES[$upload_name]['size'];
      $file_temp = $_FILES[$upload_name]['tmp_name'];
      $file_type = $_FILES[$upload_name]["type"];
      $file_err  = $_FILES[$upload_name]['error'];
  list($width, $height, $type, $attr) = $imageSizeInfo;
      $move_me = "images/users/status/".$org_name;
  if(move_uploaded_file($file_temp, $move_me)) {
      echo "{";
      echo        "msg: '".$org_name."'";
      echo "}";
  }
  if($width &gt; 604 &amp;&amp; $height &gt; 453) {
  $jpeg_quality = 90;
  $src = "images/users/status/".$org_name;
  $ext= pathinfo($src, PATHINFO_EXTENSION);
  $targ_h = 453;
  $targ_w = 604;
  $path_thumbs = "images/users/status/";
  $thumb_path = $path_thumbs . '/' . $newfilename;
  
  if($ext == "jpg" OR $ext == "jpeg" OR $ext == "JPG"){
      $img_r = imagecreatefromjpeg($src);
  }elseif($ext == "png" OR $ext == "PNG"){
      $img_r = imagecreatefrompng($src);
  }elseif($ext == "gif" OR $ext == "GIF"){ 
      $img_r = imagecreatefromgif($src);
  }
  $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
  
  imagejpeg($dst_r,$thumb_path,$jpeg_quality);
  
  unlink($move_me);
  }
  </code></pre>
  
  <p>So first it uploads the file with the original dimensions and everything, and then after it checks for dimensions and then resizes it, and unlinks(remove) the original one..</p>
  
  <p>Now I dont know what, but somehow at the resize procedure it goes wrong and i only get a black square in the dimensions 604x453 as output..</p>
  
  <p>What did i miss, how can i solve this?</p>