Optimize with PNGCrush
This article describes how to automate the pngcrush application to optimize the world files generated by Overviewer.
If you haven't already, check out Building Overviewer as we will need some files to work with for pngcrush to be useful. This script should work with any Minecraft Map Rendering software which supports the PNG image format.
This process was created using a Debian 6.0 (Squeeze) server, but this should also work on Ubuntu and Derivatives.
sudo apt-get install pngcrush
Script
Next we tie it all together with a script. Copy and paste the following code, and save it to /opt/minecraft/bin/optimize-map.sh
#!/bin/bash
##############################################
# This script will optimize the map rendering
# of your Minecraft world, using pngrush
##############################################
# This will run pngcrush on the output of overviewer to reduce size of generated maps.
# Run an additional line for each world you want to optimize.
# mtime is set to files that have been created in the last day, to speed this process up.
find /var/www/world/ -name "*.png" -mtime -1 -exec /opt/pngcrush/pngcrush {} {}.crush \; -exec mv {}.crush {} \;
Next we need to change ownership and make the script executable.
chown minecraft:minecraft /opt/minecraft/bin/optimize-map.sh chmod 774 /opt/minecraft/bin/optimize-map.sh
Cron Job
Set this to automatically run from cron from the “minecraft” user account. In this example, pngcrush will render the map at 15 minutes past the hour of 5am daily. Depending on the size of your world, and the speed of the machine used to optimize, this process can take several hours to complete.
su minecraft - crontab -e 15 5 * * * /opt/minecraft/bin/optimize-map.sh