Smaller modules

From VASSAL
Jump to: navigation, search

How do I make my module smaller?

This page is for module designers who need tips on reducing the size of their modules. Some of the tips can have a dramatic effect, others less so. Maps typically make up the largest part of any module, followed by Rule tables and Charts. Small decreases in counter size can have a major effect in large modules that might contain thousands of counter images.

Please feel free to add more tips or fill in a section I haven't got to yet!

First things first

The module file might have a name ending with .vmod. However, to manipulate your module as a zip file, you might have to change its extension (at least in Windows).

Remove old versions of images

As you build up your module, you copy additional images into the 'images' sub-folder within your module zip file. If you change the name of any images, the old versions of those images will not be deleted unless you specifically delete them. Sounds obvious, but it is a step many people forget.

Benefit can be large, especially if there are a couple of copies of old maps still in the module!

Re-zip your module

Adding and deleting files to a zip archive using Windows XP or a utility like Winzip, can leave small unusable spaces in the file that add to the total size of the archive. If you are regularly deleting or overwriting files in your module, you should periodically re-zip the module. Unzip the entire module, delete the original and re-zip the module into a new zip file.

Benefit small to medium.

Image Color Depth

Image Color Depth is a biggy. A 256 Color map requires 8 bits per map pixel. A 32 Color map requires 5 bits per pixel, an immediate reduction to 62.5% of the original size, before taking into account any additional saving due to larger area of the same color (which improves compression). Even reducing to a 64 color map will still reduce the size to 75%.

Obviously, there is a tradeoff between the number of colors and the 'prettiness' factor of the map. You should never consider using palettes larger than 8 bits (256 colors).

The PNG format is defined to have a minimum pixel depth of 8 bits. Even so, reducing the palette size prior to saving as a PNG will still result in a smaller image due to the compression mechanism used.

Benefit can be large for maps, or when many counters are defined.

Image Format

Yes. The JPEG format is designed for photographs (Joint Photographic Experts Group). In order to attain its compression levels, it throws out data. Now in a photograph, the data is thrown out in such a way that the eye doesn't notice it. But on line art (like is common on maps and counters), JPEG can introduce ringing and other artifacts, reducing the quality of the image.

Vassal also supports PNG, which gets better compression than GIF, supports (up to) a 16 bit alpha alpha channel, is supported natively under Linux, Mac OSX, and Windows (>= 98)

As an example, this is from a game of Advanced Civ I am running. Two images, one JPEG, the other PNG. I tweaked the JPEG quality setting so that the file would be the same size as the PNG.

http://broggs.org/~mcbeth/CivMap.png http://broggs.org/~mcbeth/CivMap.jpg

Be aware that most browsers automatically scale down bare images when it displays them, so click on the image in Mozilla/Firefox/etc to make it 1:1, or in IE, there is a box in the lower right you can click if you mouse over it to see the real image.

Benefit can be large for Maps.

Remove GIF Comments

GIF images can optionally include a text comment along with the image. By default, most image editors will save the name and version of the editor as a comment in each image they save. Better editors give you the option to suppress these comments in the 'Save As' dialog. There are third party tools that can remove the GIF comments from a folder full of files in batch mode.

Benefit is small if module has few counters to medium in modules with thousands of counters.

Image Resolution

Share Images Between Counters - Using Transparent GIF's

HTML Charts

Rule tables and charts are typically stored as scanned GIF images of the real charts. These can take up a substantial amount of space in a module. Consider implementing Rule tables as HTML charts.

Use an HTML editor (such as AceHTML free edition) to create good looking tables and text blocks. HTML charts have the added advantage of adjusting themselves properly as their window is resized.

From VASSAL 2.0 onwards, the <IMG> tag in HTML charts will display images from within the module images folder if not pathname is used (eg <IMG src="imageFromModule.gif">). This enables you to use counter images and small terrain examples etc. within your HTML charts instead of creating a large scanned image.

Benefit medium to large depending on number and size of charts.

Use Extensions

Extensions allow you to add functionality to your main module and distribute it as a separate file. Release your core fnctionality in your base module and then release additional maps, counters and scenarios in extensions. Users only need todownload the core module to begin with, and then the additional extensions that they need.