Sysadmins of the North

Technical blog, where topics include: computer, server, web, sysadmin, MySQL, database, virtualization, optimization and security

Optimize images for the web in bulk

Optimizing and loss-less compressing images is one of those items that always pops up when analyzing your website with Google PageSpeed Insights. Images have to be loss-less compressed to save many bytes of data and thus bandwidth. This speeds up the download time of your website. But, how do we optimize images for the web? Or, what if I have hundreds of images that needs optimization? We optimize and loss-less compress images in bulk.

Optimize images for the web in bulk with OptiPNG

In this post we optimize PNG images as example. The same goes for loss-less compressing and optimizing JPEG images, you only need another tool (jpegtran or jpegoptim).

Google PageSpeed Insights already mentions the tools, we only have to download and use them.

So, go ahead and download OptiPNG. There is no installation required, it’s a run once executable for the command line.

If you are familiar with the command line, for example on Windows 7 and higher, you can very easily execute OptiPNG with its default settings on all your PNG files in a directory:

D:\Dev\sites>
 FOR /F %I in ('dir /b/s *.png')
 do @c:\optipng-0.7.4-win32\optipng.exe %I

This will loss-less compress and optimize all PNG images in bulk, found within d:\dev\sites\ and recursively into sub directories, making your images and website-footprint smaller, resulting in a faster download of your website.

This may interest you:   How to clean up Contact Form 7 temporary captcha files on IIS web servers

Find more website optimization tips at Website optimization: minify JavaScript, CSS and compress images.

2 Comments

  1. You can also run just:
    c:\optipng-0.7.4-win32\optipng.exe *.png

    • Hi Aivar, thank you for your comment.
      Unfortunately I’m without Windows right now, but does optipng.exe recurse into directories? If yes then that is a much shorter command, thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.