I am creating images using ImageNew (and related) in Railo, which uses JAI under the covers.
When I save an image, I'm getting a 24-bit PNG, but I only need 8-bit. (Simply re-saving the file with as 8-bit with a graphics editor results a quarter to half as many bytes.)
ImageWrite doesn't offer any functionality regarding PNG bit depth, and I can't find any details of doing this with JAI itself either (getting a DNS error for http://jai-core.dev.java.net/)
Update:
Using the Quantize ImageFilter I can reduce the number of colours to 256 - this reduces the file size significantly (but still not as far as processing manually does), but still results in a 24-bit/unpaletted PNG file. Unfortunately, it also removes the transparency, which I need preserved (or at least re-applied.)
If I take the file this produces and run it through OptiPNG (a lossless PNG optimiser), it does produce the indexed 8-bit file and shaves off quite a few bytes and gives acceptable filesizes.
So, the remaining step of the puzzle: how do I re-apply transparency after ImageFilter has removed it (or better, prevent it being removed).
I guess I need some way to do Image.replace('white','transparent')
either as a Railo/Java-based solution, or a cross-platform command-line tool.