Mapnik Output Formats
Mapnik supports rendering with both AGG and Cairo (see MapnikRenderers for more detail), and can create maps or map tiles in a variety of formats.
Tradeoffs
| Mapnik Format | Renderer | Type | Visual Quality | Rendering Speed* | Size* | Relevant Code |
| png | AGG | 32-bit | png | 0.12 s | 16 KB | source:trunk/include/mapnik/png_io.hpp |
| png256 | AGG | 8-bit | png256 | 0.12 s | 8 KB | source:trunk/include/mapnik/png_io.hpp |
| jpeg | AGG | ? | jpeg | 0.12 s | 8 KB | source:trunk/include/mapnik/jpeg_io.hpp |
| ARGB32 (png) | CAIRO | 32 bit | png24 | 0.24 s | 20 KB | source:trunk/include/mapnik/cairo_renderer.hpp |
| RGB24 (png) | CAIRO | 24 bit | alpha png32 | 0.24 s | 20 KB | source:trunk/include/mapnik/cairo_renderer.hpp |
| svg | CAIRO | N/A | svg | 0.28 s | 980 KB | source:trunk/include/mapnik/cairo_renderer.hpp |
| CAIRO | N/A | 0.40 s | 232 KB | source:trunk/include/mapnik/cairo_renderer.hpp | ||
| ps | CAIRO | N/A | postscript | 0.36 s | 1.4 MB | source:trunk/include/mapnik/cairo_renderer.hpp |
* Rendering speeds and output sizes based on sample 256 X 256 tiles created using the GettingStarted sample data, run using Mapnik SVN Head (r 747), cairo 1.8.0, and pycairo 1.4.12.
More tests with complex styles, labeling are needed
PNG Quantization
In the 0.7.1 release, Mapnik gained some enhanced (beta) flexibility around reducing colors. See details at [mapnik-devel email http://lists.berlios.de/pipermail/mapnik-devel/2010-March/001081.html] and ticket #477: http://trac.mapnik.org/ticket/477#comment:10
- c=256 - limit number of colors (default 256), works with octree and
hextree
- t=2 - select transparency mode: 0-no alfa, 1-binary alfa(0 or 255),
2-full alfa range, default is 2, works with octree and hextree
- m=o - choose quantization method, available options: o-existing
octree, h-new hextree with optimizations, default is octree
- g=2.0 - kind of gamma correction for pixel arithmetic in hextree
method, default value 2.0 worked best with most of my test images, value
1.0 means no gamma correction.
So to use new format i.e. in python:
view.save("test.png",'png256:m=h')
or other example in c++:
save_to_file(vw, "test.png", "png256:t=1:c=128");
Tradeoffs
TODO: discussion of tradeoffs and situations to use which format
