Using wesnoth-optipng

In order to reduce Wesnoth’s on-disk space consumption as much as possible, the mainline developers have developed a script using various PNG re-encoding tools to minimize their image files’ size. This does not always work well as some files are already at their optimal compression level, but it can do wonders with larger images produced by some applications from time to time.

Wesnoth-UMC-Dev staff use this tool too when importing add-ons from new applicants, and it might be worth a try for your add-on if the bulk of it appears to consist of large portraits, terrain or unit graphics. It should be noted that the conversions done by it are completely lossless — i.e. there won’t be any modifications to the actual pixel map contents, only to the method using for compressing and storing it in the image files.

wesnoth-optipng is part of the official Wesnoth source code distribution and can be found under the utils/ directory.


This tool uses the GNU bash scripting language, and requires OptiPNG, Advdef and ImageMagick's convert utilities to be installed and available in PATH. On GNU/Linux distributions these applications can be easily obtained through your package manager of choice.

Command line reference


wesnoth-optipng [SWITCHES] [FILES]

wesnoth-optipng may be run to optimize all PNG files under the current directory and its subdirectories (default), or on a specific set of files specified in the command line.

Configuration options

Switch Description
-n, --nice <value> Sets the process nice value under which the optimization shall be done. If not specified, the default of 19 is assumed (lowest priority).
--threads <value> Runs the script with value worker threads. If not specified, the amount of CPU cores detected will be used by default.
Generated in 0.002 seconds.
This page was last modified on Thu Dec 09 22:33:53 CET 2010.