Here’s a tool I built out of convenience. At work, we were doing heavy optimizations for a large vehicle manufacturer’s website. One of the big savings we were constantly able to perform page to page was reducing the size of PNG files wherever they were used with the help of a tool called TinyPNG. The problem is that there’s a limit of processing 20 files at a time and you have to manually upload and then download each PNG file. This becomes a tedious process when you’re working with a very large collection of PNG files. So I went ahead and built a tool called Hulk Smash.
Hulk Smash allows you to compress entire directories of PNGs with a single command.
Download Hulk Smash (only for Mac OS X)
1. Give execute permissions to the bash script (sudo chmod +x hulksmash.sh)
2. Run hulksmash on a given directory with the d parameter (sudo ./hulksmash.sh -d ~/PATH/TO/PNG/DIR)
That’s it! Hulk Smash will now install the dependencies required which may take awhile. Once that is done, Hulk Smash will backup your directory of PNGs onto the same level where the current directory is before beginning optimization. About halfway through, the ImageOptim program will open, wait until the program is complete its optimizations before closing it. Once it’s done, close ImageOptim and Hulk Smash will output the result of the optimizations performed.
So how does Hulk Smash compare to TinyPNG? I created a test directory of 20 PNG files which was 734.713KB in total. These 20 PNG files consisted of sprites, icons, and various other image assets pulled from a variety of large websites online such as Target, Walmart, Nike, Chrysler, JCPenney, and IKEA amongst others. So what were the results?
TinyPNG: 60% savings (reduced by 324 KB)
Hulk Smash: 61.69200% savings (reduced by 442.642KB)
In this test case, Hulk Smash saved an extra 118.642KB!
Notes & Dependencies
Also I hold no responsibility for any damage this script may cause. I’ve done my best to test the tool and to the best of my knowledge it has worked wonderfully for me so I hope it’s a useful tool for you as well.