Thursday, December 23, 2010

magicktiler

Check out magicktiler, a Java tool and embeddable library for converting images into formats suitable for publishing as zoomable Web images. It supports a variety of tiling schemes (TMS, Zoomify, Google Maps, ..). You can find some detailed information in the slides I used for my talk at the Toronto JUG.

It has a CLI, a Scala-Swing based GUI and can be used as a Java lib:
public static void main(String... args) {
    try {
        File input = new File("/path/to/your/image.jpg");
        File output = new File("/tileset/output/path");
        
        MagickTiler tiler = new GoogleMapsTiler();
        // optional settings (these are the default values)
        tiler.setTileFormat(ImageFormat.JPEG);
        tiler.setJPEGCompressionQuality(75);
        tiler.setBackgroundColor("#ffffffff");
        tiler.setWorkingDirectory(new File("."));
        tiler.setGeneratePreviewHTML(true);
                
        // create the tiles
        TilesetInfo info = tiler.convert(input, output);
    } catch (TilingException te) {
        te.printStackTrace();
    }
 }