title: php resize image without loss quality
body: <p>i've implement this method (by following php tutorial) for create preview of an images:</p>
  
  <pre><code>function createPreview($image_path, $filename) {
  
      header('Content-Type: image/jpeg');
      $thumb = imagecreatetruecolor(350, 350);
      $source = imagecreatefromjpeg($image_path);
  
      list($width, $height) = getimagesize($image_path);
  
      imagecopyresized($thumb, $source, 0, 0, 0, 0, 350, 350, $width, $height);
  
      imagejpeg($thumb, $filename."_prev.jpg");
  }
  </code></pre>
  
  <p>but i've noticed that scaled image loss a lot of quality. How can i preserve quality of scaled image (i can't use imagick, my server doesn't support it)</p>