Make the size of product pictures smaller in bulk - less bytes - more speed

This is a fast trick to get all your uploaded product pictures smaller in size. I hope that most of your files are in JPG, this makes it easier because the tool you are going to use will most likely not change extension of the better compressed image file. If it will not then it is a direct replacement… overwrite and you are done.

Yahoo application Smash-It, here is a trick to fool it to process most of your files in easy 8 steps:

  1. Get Firefox and an add-on YSlow.
  2. Put this code as images.php in the root of the domain of your store.
  3. Run the php file, it will list and display all product images on one page.
  4. On this page run YSlow, go to tools, go to Smash-It, it will load a new page analyzing listed images.
  5. Wait until all files are done, download the single ZIP file of all newly compressed images, unzip to some temp directory
  6. Look for files that have changed extensions, like *.gif.png and *.jpg.png or similar
  7. Delete files if such found in step #6.

    8.) Upload to /images/product via FTP

    Enjoy smaller loading times even if it is only 5% less. However, images take the largest (like 75%) of html loading time. Depending on your luck, you can save a lot of transfer bandwidth and make your site more snappy.

    Code for PHP is below:

<?<br />
<br />
$d=dirname(__file__);<br />
$dd='/images/product';<br />
$d.=$dd;<br />
<br />
if ($handle = opendir($d)) {<br />
    while (false !== ($file = readdir($handle))) {<br />
		$t=pathinfo($file);<br />
		if(($t['extension']=='gif')||($t['extension']=='png')||($t['extension']=='jpg'))<br />
			echo "<hr>$file     <img src='$dd/$file' border='0' align='center'>";<br />
    }<br />
    closedir($handle);<br />
}<br />
?><br />

If you don’t want to use firefox and yslow addon, you can use this:

[url][/url] ← choose URL tab

and change php to:



if ($handle = opendir($d)) {
while (false !== ($file = readdir($handle))) {
echo "http://$ddd$dd/$file


This will generate a list of picture links in text format. Copy and paste to that sites box under URL, that is once you click on URL tab.