PHP & Yahoo Smush It
Whenever one of my projects has finished, I use the Firebug plugin ySlow to analyse the speed of the page.
They have one neat feature called SmushIt. This can cut down image sizes up to 80% which ofcourse has a massive impact on your page’s loading time.
However, once a project has finished, and there is some sort of image generation in the backend of the website, or a file uploading system, we also want those images to be as fast as possible, and therefor I have written this PHP class. Lets hope Yahoo still likes me after this.
You can also read this post here
How it works:
You pass the image you want to smush, and the url of the result image to the class, and thats it!
<? require_once('SmushIt.php'); $goto = dirname(__FILE__); $smush = new SmushIt; $smush->base = 'http://www.frankbr.nl/projects/smushit/'; if( !$smush->smush('img/image.png','img/image-smushed.png') ) { echo $smush->msg; } else { echo 'saved: ' . $smush->savings . 'kb (' . $smush->savings_perc . '%)'; }
Demo:
Demo page
Unsmushed image
Smushed image
Download:
Click here to download SmushIt.php
Reageer