Change the output format of the map

View example

Depending on the format you choose, the image may not appear in your browser. If the link does not appear in your browser, right-click on the image above to see what save format is specified in the MapFile.

The following is the Mapfile (xmfa8.map) used in this example:

01 MAP
02     IMAGETYPE "PNG24"
03     EXTENT -180 -90 180 90
04     SIZE 600 300
05     SHAPEPATH "/gdata"
06     IMAGECOLOR 255 255 255
07     FONTSET "../fonts/fonts.list"
08     SYMBOLSET "../symbols/symbols35.sym"
09     OUTPUTFORMAT
10         NAME "png"
11         DRIVER "GD/PNG"
12         MIMETYPE "image/png"
13         IMAGEMODE PC256
14         EXTENSION "png"
15     END
16     OUTPUTFORMAT
17         NAME "png24"
18         DRIVER "GD/PNG"
19         MIMETYPE "image/png"
20         IMAGEMODE RGBA
21         EXTENSION "png"
22     END
23     OUTPUTFORMAT
24         NAME "GTiff"
25         DRIVER "GDAL/GTiff"
26         MIMETYPE "image/tiff"
27         IMAGEMODE RGB
28         EXTENSION "tif"
29     END
30     OUTPUTFORMAT
31         NAME "AGG"
32         DRIVER "AGG/PNG"
33         IMAGEMODE RGB
34     END
35     OUTPUTFORMAT
36         NAME "AGGA"
37         DRIVER "AGG/PNG"
38         IMAGEMODE RGBA
39     END
40     OUTPUTFORMAT
41         NAME "AGGJ"
42         DRIVER "AGG/JPEG"
43         IMAGEMODE RGB
44     END
45     LAYER
46         NAME "land-shallow-topo"
47         DATA "land_shallow_topo_8192.tif"
48         STATUS OFF
49         TYPE RASTER
50         PROCESSING "BANDS=1,2,3"
51         OFFSITE 71 74 65
52     END
53     LAYER
54         NAME "wcountry-line"
55         DATA "wcountry.shp"
56         STATUS OFF
57         TYPE LINE
58         CLASS
59             NAME "State Boundary"
60             STYLE
61                 SYMBOL "line5"
62                 COLOR 255 255 0
63                 SIZE 1
64             END
65         END
66     END
67 END

The file changes are as follows:

2    IMAGETYPE "PNG24"2    IMAGETYPE "PNG24"
n3    EXTENT -20042150 -20000000 20104978 20000000n3    EXTENT -180 -90 180 90
4    SIZE 400 4004    SIZE 600 300
5    SHAPEPATH "/gdata"5    SHAPEPATH "/gdata"
nn6    IMAGECOLOR 255 255 255
7    FONTSET "../fonts/fonts.list"
6    SYMBOLSET "../symbols/symbols35.sym"8    SYMBOLSET "../symbols/symbols35.sym"
n7    FONTSET "../fonts/fonts.list"n9    OUTPUTFORMAT
8    PROJECTION10        NAME "png"
9        "init=epsg:3857"11        DRIVER "GD/PNG"
12        MIMETYPE "image/png"
13        IMAGEMODE PC256
14        EXTENSION "png"
15    END
16    OUTPUTFORMAT
17        NAME "png24"
18        DRIVER "GD/PNG"
19        MIMETYPE "image/png"
20        IMAGEMODE RGBA
21        EXTENSION "png"
22    END
23    OUTPUTFORMAT
24        NAME "GTiff"
25        DRIVER "GDAL/GTiff"
26        MIMETYPE "image/tiff"
27        IMAGEMODE RGB
28        EXTENSION "tif"
29    END
30    OUTPUTFORMAT
31        NAME "AGG"
32        DRIVER "AGG/PNG"
33        IMAGEMODE RGB
34    END
35    OUTPUTFORMAT
36        NAME "AGGA"
37        DRIVER "AGG/PNG"
38        IMAGEMODE RGBA
39    END
40    OUTPUTFORMAT
41        NAME "AGGJ"
42        DRIVER "AGG/JPEG"
43        IMAGEMODE RGB
10    END44    END
11    LAYER45    LAYER
n12        NAME "states"n46        NAME "land-shallow-topo"
13        DATA "wcountry.shp"
14        STATUS OFF
15        TYPE POLYGON
16        PROJECTION
17            "init=epsg:4326"
18        END
19        CLASS
20            NAME "States"
21            EXPRESSION "land"
22            STYLE
23                COLOR 232 232 232
24            END
25        END
26    END
27    LAYER
28        NAME "modis"
29        DATA "land_shallow_topo_8192.tif"47        DATA "land_shallow_topo_8192.tif"
32        PROCESSING "BANDS=1,2,3"50        PROCESSING "BANDS=1,2,3"
n33        PROJECTIONn51        OFFSITE 71 74 65
34            "init=epsg:4326"
35        END
36    END52    END
37    LAYER53    LAYER
n38        NAME "states"n54        NAME "wcountry-line"
39        DATA "wcountry.shp"55        DATA "wcountry.shp"
41        TYPE LINE57        TYPE LINE
t42        PROJECTIONt
43            "init=epsg:4326"
44        END
45        CLASS58        CLASS

Now our MapFile contains a new object, OUTPUTFORMAT . This object is defined within the MAP object and is used with the keyword IMAGETYPE. According to the compiled library of MapServer, you can choose from a variety of output formats - GD library provides PNG (8-bit and 24-bit), GIF, JPEG, WBMP, GDAL library, and many input formats of MapServer, it can also provide output PNG , JPEG, TIFF/GeoTIFF, and other raster formats; The pdflib library provides PDF output.

Have a look at the object and experiment OUTPUTFORMAT by changing the keyword IMAGETYPE to your MAPFILE. Should be used as the value of your IMAGETYPE (for example: IMAGETYPE png or PNG24 IMAGETYPE), the name of the output format.

Please consult the OUTPUTFORMAT object reference:

http://www.mapserver.org/mapfile/outputformat.html#outputformat