title: Resize an image and maintain quality?
body: <p>I have a problem with resizing images.</p>
  
  <p>What happens is that if you upload a file larger than the stated parameters, the image is cropped, then saved at 100% quality.</p>
  
  <p>So if I upload a large jpeg which is 272Kb. The image is cropped by 100 odd pixels. The file size then goes up to 1.2Mb.</p>
  
  <p>We are saving images at a 100% quality. I assume that this is what is causing the problem. The image is exported from Photoshop at 30% quality which reduces the file size. Resaving the image at 100% quality creates the same image but I assume with a lot of redundant file data.</p>
  
  <p>Has anyone encountered this before? Does anyone have a solution?</p>
  
  <p>This is what we are using.</p>
  
  <pre><code>$source_im = imagecreatefromjpeg ($file);
  $dest_im = imagecreatetruecolor ($newsize_x, $newsize_y);
  imagecopyresampled (
      $dest_im, $source_im,
      0, 0,
      $offset_x, $offset_y,
      $newsize_x, $newsize_y,
      $sourceWidth, $sourceHeight
  );
  
  imagedestroy ($source_im);
  if ($greyscale) {
      $dest_im = $this-&gt;imageconvertgreyscale ($dest_im);
  }
  imagejpeg($dest_im, $save_to_file, $quality);
  break;
  </code></pre>