THIS PROJECT IS OBSOLETE
I have moved my maintenance efforts entirely to the legends processor module of the PyLNP, which is more stable and efficient. While this bundle will remain available, I suggest using the PyLNP instead unless you have good reason not to.
A simple script to compress and sort the files exported from Dwarf Fortress' Legends Mode.
Compressing the .bmp maps to .png usually reduces file size by 95 to 99+ percent (yes, really).
Compressing the legends.xml, which is tens to hundreds of MB, often reduces the file size by a similar margin.
The script then moves the compressed files to region-specific folder and puts site maps and world maps in separate subfolders.
To get a copy, can use the 'download as a zip' option on the right and place the whole unzipped folder in the LNP/utilities folder of the DF Starter pack or the contents in the same folder as the Dwarf Fortress executable.
This script is released under the GPL3. License files for 7zip and OptiPNG are included.
General overview of functions:
Find the folder to work in (must contain "Dwarf Fortress.exe"), either in current folder or the relative path from a Starter Pack utilities folder
Establish which region's exports we're working with, by iterating back from 99 and looking from a match. Display message explaining function of the script if nothing is found.
Call OptiPNG to compress the bitmaps to PNG format.
Call 7zip to compress the legends XML in .zip format. If all required files are available, an archive compatible with "Legends Viewer" will be created (includes other text history files and a map).
Move all output files to a "User Generated Content" folder next to the Dwarf Fortress folder, and delete color key text files.
The Python version is written for Python 3 as a cross-platform implementation.
It is more robust regarding unexpected circumstances, and uses the built-in zipfile function instead of 7z.
However, it isn't quite cross-platform as I'm unsure how to comvert bitmaps without optipng available.
It must be run in the DF folder, and won't work from anywhere else - unlike the .bat version.