I came to know of yahoo!’s awesome lossless image compression service smush.it through this blog post. After playing around with smush.it for sometime I realised that there is no command line client that does it to images in local directories. So thought why not write one and this is the result – https://bitbucket.org/abhirama/smushit. You can download the binary from github.

Directions for use:
This is a command line tool which losslessly compresses all the images in the passed directory using yahoo!’s smush.it image compression utility – http://www.smushit.com/ysmush.it/, downloads the smushed images and replaces the original image with the smushed ones in their respective directories.

java -jar smushit.jar [options]

Mandatory options:
Root directory of the images to be smushed. The program recursively traverses all sub directories of this directory smushing images.

Optional Options:
Will print detailed messages on screen.
Will not download the smushed images.
Specify a list of comma separated image extensions. Only images with those extensions will be smushed.

Example usage:
java -jar smushit.jar -imageDir=/foo -verbose=true -dryRun=false -imgExtensions=gif,png,jpeg

The above will smush all images with extensions gif, png and jpeg in directory foo and it’s sub directories and will download the smushed images and replace the original with the smushed images.

Sometimes smushit converts gifs to pngs if the resulting png files are smaller. Take a look at this faq – http://developer.yahoo.com/yslow/smushit/faq.html#faq_giftopng . If this happens with your images, your image folder will have the original image as well as the newly converted png image.

Give it a spin and let me know if there are any bugs or any enhancements needed. It is in a fledgling state and I will keep on improving it in the coming days.

PS:If this interests you, take a look at this python script.

PS:If you want to run this as a batch file in windows, follow the instructions posted by here.

About these ads