title: Resize an image and save with imagejpeg()
body: <p>iam trying to resize an imageto a thumbnail with php! I get no errors but it won't save the thumbnail on my server. The code is:</p>
  
  <pre><code>#Resize image
  function resize($input_dir, $cur_file, $newwidth, $output_dir)
  {
      $filename = $input_dir.'/'.$cur_file;
      $format='';
      if(preg_match("/.jpg/i", $filename))
      {
          $format = 'image/jpeg';
      }
      if (preg_match("/.gif/i", $filename))
      {
          $format = 'image/gif';
      }
      if(preg_match("/.png/i", $filename))
      {
          $format = 'image/png';
      }
      if($format!='')
      {
          list($width, $height) = getimagesize($filename);
          $newheight=$height*$newwidth/$width;
          switch($format)
          {
              case 'image/jpeg':
              $source = imagecreatefromjpeg($filename);
              break;
              case 'image/gif';
              $source = imagecreatefromgif($filename);
              break;
              case 'image/png':
              $source = imagecreatefrompng($filename);
              break;
          }
          $thumb = imagecreatetruecolor($newwidth,$newheight);
          imagealphablending($thumb, false);
          imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
          imagejpeg($thumb, 'thumb_'.$cur_file);
      }
  }
  </code></pre>
  
  <p>My function looks like:</p>
  
  <pre><code>resize(plugins_url().'/MyImagePlugin/img', 'testimg.jpg', "200");
  </code></pre>
  
  <p>The Image is in the Folder "img" in my Plugin Dic. The wired thing is ,that i don't get any erros?! CHMOD is 777 for img-folder.</p>
  
  <p>Any help would be appreciated.</p>