Posted by & filed under QGIS.

This has been done before by others, but its always interesting to look at image quality versus size when starting a new project. Each project has different types of data and thuse different optimal configuration. Here is a simple breakdown of size vs quality I did for a project.

First let me show you my mapserver image format definitions…:

  OUTPUTFORMAT
    NAME 'AGG_Q'
    DRIVER AGG/PNG
    IMAGEMODE RGB
    FORMATOPTION "QUANTIZE_FORCE=ON"
    FORMATOPTION "QUANTIZE_DITHER=OFF"
    FORMATOPTION "QUANTIZE_COLORS=256"
  END 

  OUTPUTFORMAT
    NAME 'AGG_JPEG'
    DRIVER AGG/JPEG
    IMAGEMODE RGB
  END 

  OUTPUTFORMAT
    NAME          "AGG_PNG"
    DRIVER        "AGG/PNG"
    IMAGEMODE     RGB
    TRANSPARENT   ON
    EXTENSION     "png"
    FORMATOPTION  "INTERLACE=OFF"
  END 

  OUTPUTFORMAT
    NAME          "AGGA_PNG"
    DRIVER        "AGG/PNG"
    IMAGEMODE     RGBA
    TRANSPARENT   ON
    EXTENSION     "png"
    FORMATOPTION  "INTERLACE=OFF"
  END 

  OUTPUTFORMAT
    NAME "GD_JPEG"
    DRIVER "GD/JPEG"
    MIMETYPE "image/jpeg"
    IMAGEMODE RGB
    EXTENSION "jpg"
  END

  OUTPUTFORMAT
    NAME "GD_PNG"
    DRIVER "GD/PNG"
    MIMETYPE "image/png"
    IMAGEMODE RGB
    EXTENSION "jpg"
  END

Now lets look at how each performed in terms of rendering quality versus file size:

File Size : 10.5kb Format: RGB JPEG using GD renderer

File Size : 19.7kb Format: RGB Png using GD renderer

File Size : 11.9kb Format: RGB Quantised Png using AGG renderer

File Size : 37.6kb Format: RGB Standard PNG using AGG renderer

File Size : 37.6kb Format: RGBA Png using AGG renderer

To be fair I haven’t added the needed ANTIALIAS clauses for the GD renderer to produce anti-aliased images for true comparison with AGG. That said even GD at it’s best isn’t a patch on AGG in my opinion. Needless to say In this project I’ve gone with the Quantised AGG outputs which are almost as small as GD JPEG images but with much nicer quality.

Note: Updated 1 March to inline images rather having to click to view the full size.

pixelstats trackingpixel

4 Responses to “Comparing renderers in Mapserver”

  1. lucap

    Interesting, any difference in rendering speed/performance ?

  2. Tim Sutton

    I didn’t test performance – a good topic for a future post! I believe the AGG renders more slowly but don’t have the stats to back that up.

  3. lucap

    Do you have any history case of using mapserver on high traffic websites ? I’m quite interested to implement a mapserver solution with the integration of OpenStreetMap data.

Leave a Reply

You must be logged in to post a comment.