title: Optimize uploaded images with php (jpeg)
body: <p>When running Page Speed in Google Chrome it suggests to optimize/compress the images. These images are mostly uploaded by users, so I would need to optimize them during uploading. What I find about optimizing jpeg images with php is something like using the following GD functions:</p>
  
  <pre><code>getimagesize()
  imagecreatefromjpeg()
  imagejpeg()
  </code></pre>
  
  <p>Since I am resizing the images after upload I'm already pulling the image through these functions and in addition I use <code>imagecopyresampled()</code> after <code>imagecreatefromjpeg()</code> to resize it. </p>
  
  <p>But then, Page Speed is still telling me these images can be optimized. How  can I accomplish this optimisation in a php script? Set the quality lower in imagejpeg() doesn't make a difference either.</p>