< Navigation

Queries >

## 8. Image Format Options

The plugin images is the core plugin that deals with the formatting options for the main map. It handles the size of the image and its filetype.

## 8.1. Client-side Configuration

### 8.1.1. Main Map Options

Here are the options that can be set:

- mapSizesActive: boolean; if true, displays a drop-down list of available mapsizes ; if false a fixed size is used (defined by the two following parameters).
- mapWidth: mainmap width in pixels if mapSizesActive = false
- mapHeight: mainmap height in pixels if mapSizesActive = false
- mapSizes.#.width : (#=0,1,2...) available mainmap width in pixels for mapsize # (when mapSizesActive = true)
- mapSizes.#.height : (#=0,1,2...) available mainmap height in pixels for mapsize # (when mapSizesActive = true)
- mapSizes.#.label : (#=0,1,2...) label that describes mapsize #; appears in drop-down list. If not specified, a <width>x<height> pattern is used as the label.
- mapSizesDefault : integer indicates the default mapsize to be used (among the above #). Only when mapSizesActive = true.
- maxMapWidth : maximum allowed width in pixels of the generated mainmap when setting manually the mapsize using GET or POST requests. If no value is specified, default max width is 1500 px.
- maxMapHeight : maximum allowed height in pixels of the generated mainmap when setting manually the mapsize using GET or POST requests. If no value is specified, default max height is 1000 px.

If no mapsize settings are found, the default mapsize is 400x200 pixels.

### 8.1.2. Keymap and Scalebar Options

The plugin images can also deal with few keymap and scalebar options:

- collapsibleKeymap: if true, keymap is shown on map, and possibly hidden.
- noDrawKeymap: if true, keymap will not be drawn at all.
- noDrawScalebar: if true, scalebar will not be drawn.

## 8.2. Server-side Configuration

Here are the options that can be set:

- maxMapWidth: maximum allowed width in pixels of the generated mainmap. If the value requested by the client is greater, maxMapWidth takes precedence over it.
- maxMapHeight: maximum allowed height in pixels of the generated mainmap. If the value requested by the client is greater, maxMapHeight takes precedence over it.

## 8.3. Related Elements in Mapfile

### 8.3.1. General Image Type

The general output fileformat is handled by Mapserver. The basic command in the mapfile is

    IMAGETYPE png|jpeg|gif...

Then the OUTPUTFORMAT objects may set properties for each possible fileformat. Example (for jpeg) :

    OUTPUTFORMAT
      NAME jpeg
      DRIVER "GD/JPEG"
      MIMETYPE "image/jpeg"
      IMAGEMODE RGB
      FORMATOPTION QUALITY=85
      EXTENSION "jpg"
    END

See the available options for each format in the Mapserver doc.

Important note if you intend to use pdf printing : interlaced png images are not supported by the fpdf library that is used in this module. Consequently, you must have the option

    FORMATOPTION "INTERLACE=OFF"

in the definition of the png OUTPUTFORMAT. Here is the complete object :

    OUTPUTFORMAT
      NAME png
      DRIVER "GD/PNG"
      MIMETYPE "image/png"
      IMAGEMODE PC256
      EXTENSION "png"
      FORMATOPTION "INTERLACE=OFF"
    END

### 8.3.2. Automatic Image Type Switch

It is often desirable to adapt the imagetype of the map to the represented data. Typically, vector data is well rendered in png, while the colors of a raster background require either jpeg or png24 format. CartoWeb includes a mechanism that automatically switches the format when specific layers are selected. A special metadata of the layers triggers this behavior :

    METADATA
      ...
      "force_imagetype" "jpeg|png..."
      ...
    END

This metadata overrides the general fileformat of the mainmap (but not of the legend icons; these stay in the initial fileformat).