title: Optimizing Images via PHP
body: <p>I would like to build a PHP script to optimize images similarly to how PunyPNG or Kraken.io optimizes images. Essentially, I would need to be able to take .jpeg, .png, and .gif images and reduce their file size as much as possible without losing quality (or with minimal quality loss).</p>
  
  <p>These services offer APIs, but I would like to avoid unnecessary costs, and I do not want to be limited by a specific number of daily uses.</p>
  
  <p>Can this be done with something like ImageMagick? Is it even possible, or is it far too complicated?</p>