Optimizing PNG Compression of Scanlations (Compressing Further)
I just want to share something that could help optimize (compress further) the compression used in PNG files to save disk space and connection bandwidth.
PNG files can usually be compressed further by utilizing these two, free, open-source PNG compression optimizers: OptiPNG (http://en.wikipedia.org/wiki/OptiPNG ) and AdvanceCOMP ( http://en.wikipedia.org/wiki/AdvanceCOMP ).
(Note: The ff. instructions are for Windows. Linux users will have to download and configure a different version of these files from the websites of these programs.)
I have compiled these two programs (currently, the latest versions [2009-08-21] ) along with a batch (.bat) file that configures these programs to use their maximum PNG compression methods so that they could be easily used to further compress a directory of PNGs or a single PNG file.
Download them here:
These programs will be utilized by putting a shortcut to these batch files in Windows' SendTo folder.
In Windows XP:
- First, extract the downloaded 'PNG Compression Tools.7z' file contents to the Program Files folder. You will have to modify the batch files if you install to a different directory (the batch files can be modified by any text editor).
- There should now be a folder called 'PNG Compression Tools' in Program Files directory.
- Open the 'PNG Compression Tools' folder and then open the 'Scripts' folder inside it.
- Select the batch (.bat) files and then copy (right click or ctrl-c) the batch files.
- Go to the 'SendTo' folder
Windows Vista / 7:
- Open a run window (WinKey + R).
- Type sendto and hit enter.
Once in the SendTo folder:
- Open a run window (WinKey + R).
- Type (or paste) %appdata%\Microsoft\Windows\SendTo and hit enter.
- Right Click->Paste Shortcut
To re-compress a PNG file or a directory with PNG files inside:
Right-click the PNG file or directory with PNG files , go to Send To > 'Re-Compress PNGs' or 'Re-Compress PNGs in Folder'. A command window will appear and you will see the output of OptiPNG and then AdvanceCOMP as they re-compress each PNG file. OptiPNG/AdvanceCOMP will not overwrite your PNG file if the output file size would be larger.
The scripts are designed to call OptiPNG and AdvanceCOMP executables from the C:\Program Files folder. If you choose to extract the files to another directory, simply modify the .BAT files to point to the directory where you extracted the programs.
7-zip ( Link - PNG Compression Tools.7z ) or PeaZip ( http://www.7-zip.org/ ) (both are freeware and open source) can be used to extract (and compress) .7z files. They can also extract ZIP and RAR files among other file formats.
The batch scripts files above have only been tested on the 32 bit versions of Windows XP and Windows 7. (Although they should work for 64 bit versions and for Vista too).
In the scripts above, OptiPNG is configured to apply the timestamp of the original file to the new one. I haven't found a way to do this with AdvanceCOMP, so PNG files optimized using the above batch file will have their timestamps updated once re-compressed.
It is necessary to use OptiPNG first, because OptiPNG performs a more advanced re-compression of the PNG file. It applies delta filters, removes unnecessary data chunks, and reduces the bit depth if possible (without reducing quality). AdvanceCOMP simply uses the 7-zip DEFLATE (.ZIP compression) algorithm (which is more effective than the standard one) to make the file smaller.
OptiPNG can also be used to covert gif, bmp, pnm, and certain tiff images to png. (You will have to configure the 'by folder compression' mode of the batch files to include these other types of files. The single file compression mode should work fine.)
The batch file should work fine even if OptiPNG or AdvanceCOMP is updated to newer versions (see links to get the latest versions below). They won't work anymore if the arguments that the programs accept are changed. That is unlikely to happen, though.
Alternatively, OptiPNG also has third party GUI programs that you can use (see the OptiPNG link below on where to get them).
Links to the programs used:
A guide to PNG Optimization: http://advancemame.sourceforge.net/comp-readme.html
Last edited by galacticninja; 01-13-2011 at 08:34 AM.
Reason: added info