Here is a quick registry hack to add a new entry “Run PNGOUT on Folder” to your context menu. It will iterate through all the files in the directory, and run PNGOUT on every PNG file it finds. It will leave all the other files alone, so you don’t have to worry about errors, or data corruption. Simply copy the code below:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT] @="Run PNGOUT on Folder" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT\command] @="cmd.exe /c \"TITLE Running PNGOUT on %1 && FOR /r \"%1\" %%f IN (*.png) DO pngout \"%%f\" \""
Paste it into notepad, save it as a .reg file, and run it by double clicking it. It should install the extension for you. This will come useful if you need to optimize a whole folder of files at once. The script should recourse into sub folders, so you can run it on the root of your website, then go to sleep and wake up to a fully PNG optimized web page.
If you want to remove this context menu item it at some point, repeat the whole procedure with:
Windows Registry Editor Version 5.00 [-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT] [-HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\PNGOUT\command]
Please note that this script assumes that PNGOUT.exe is somewhere in your path. If it’s not, make sure you put it in a folder within your path to ensure the script works.
Just for the sake of completion, Scott Hanselman created very similar registry hack, allowing you to run PNGOUT on a single file.
[tags]pngout, png, png compression, png size reduction, registry, hax[/tags]