Free mobile recharge for 10 lucky winners participate in this giveaway
HackingUniversity - Hacks . Tricks . How-To's

22 March 2013

Automate Image Compression in Windows via Context Menu

compress images

Image compression is a must thing when you are in the business of blogging. You blog too much and images usually increase your visitors response rate and hence also your blogs size. So resulting in slow loading speeds and more bandwidth problems.

Well we already posted an easy simple too use tool called Riot that does lossless image optimization and works pretty well but Christopher Olberding has something much more convenient too offer us. Well by convenient I mean its easy to be applied but still after I gave it a try it lacks the optimum image optimization level but still works pretty awesome.

Well as you can see in the above image you can easily compress any folder with image using an easy context menu option called "Optimize Image" so as soon as you click on that a command prompt window will popup and start compressing your image. So jump in too below tut and see how it works.

  1. Download this package containing your compressors and processing file you can obviously check for newer version of them @ jpegtran and pngout and replace the file in the package provided.
  2. Now after downloading the above package just extract it and put the "Image Optimization folder" in C:/Program Files/
  3. Now your folder is place with compressors and Optimize.bat file in it which contains the following below code.
    @echo none
    cd %1
    md "%~1\OptimizedJPEGS"
    for %%i in (*.jpg) do "C:\Program Files\Image Optimization\jpegtran.exe" -optimize -progressive -copy none "%%i" "%~1\OptimizedJPEGS\%%i"
    move /Y "%~1\OptimizedJPEGS\*.*" "%~1"
    rd "%~1\OptimizedJPEGS"
    for %%i in (*.png) do "C:\Program Files\Image Optimization\pngout.exe" "%%i"
  4. Now we need to add the option in context menu as you can see, well it needs a little registry tweak just open "Registry Editor"
  5. Now browse to HKEY_CLASSES_ROOT\Directory\shell\ and right click on shell and create a New > Key and enter the name you want to have in your context menu like "Optimize Images"

    registry editor
  6. Now you need to right click on Optimizes Images and create another Key and now double click on the Default and enter the below code in it.
  7. That’s it your steps are completed and now you will be having a new option in your context menu try optimizing images in any folder with jpeg or png images. As soon you will click on Optimize Images option you will see CMD popup processing your images on its algorithms.

    command prompt compression

Now you can easily start compressing and optimizing your images in bulk and that too on the go using easy context menu options well there are still something's you need to be aware off.

Remember This script will not process images placed in Sub-Folders make sure all the images are kept in one main folder. And image compression is good and entirely lossless so you might not see a huge difference.

Once again thanks to Christopher Olberding from StationFour.com for providing me with this easy work around for compressing images.