2.3. Change the output format of the map#
2.3.1. View examples#
Depending on the format you choose, the image may not be displayed in your browser. If the link doesn’t appear in your browser, right-click on the image above to see what format is specified in MapFile for saving.
Mapfile example#
The following is the Mapfile used in this example mfa8.map
):
1MAP
2 EXTENT -180 -90 180 90
3 SIZE 600 300
4 SHAPEPATH "/gdata"
5 IMAGECOLOR 0 0 255
6 FONTSET "../fonts/fonts.list"
7 SYMBOLSET "../symbols/symbols35.sym"
8 IMAGETYPE "PNG24"
9 OUTPUTFORMAT
10 NAME "png8"
11 DRIVER "AGG/PNG8"
12 MIMETYPE "image/png; mode=8bit"
13 IMAGEMODE RGB
14 EXTENSION "png"
15 FORMATOPTION "QUANTIZE_FORCE=on"
16 FORMATOPTION "QUANTIZE_COLORS=256"
17 FORMATOPTION "GAMMA=0.75"
18 END
19 OUTPUTFORMAT
20 NAME "png"
21 DRIVER "AGG/PNG"
22 IMAGEMODE RGB
23 END
24 OUTPUTFORMAT
25 NAME "png24"
26 DRIVER "AGG/PNG"
27 IMAGEMODE RGBA
28 TRANSPARENT TRUE
29 END
30 OUTPUTFORMAT
31 NAME "jpeg"
32 DRIVER "AGG/JPEG"
33 IMAGEMODE RGB
34 END
35 OUTPUTFORMAT
36 NAME "svg"
37 DRIVER "CAIRO/SVG"
38 MIMETYPE "image/svg+xml"
39 IMAGEMODE RGB
40 EXTENSION "svg"
41 END
42 OUTPUTFORMAT
43 NAME "pdf"
44 DRIVER "CAIRO/PDF"
45 MIMETYPE "application/x-pdf"
46 IMAGEMODE RGB
47 EXTENSION "pdf"
48 END
49 OUTPUTFORMAT
50 NAME "cairopng"
51 DRIVER "CAIRO/PNG"
52 MIMETYPE "image/png"
53 IMAGEMODE RGB
54 EXTENSION "png"
55 END
56 OUTPUTFORMAT
57 NAME "GTiff"
58 DRIVER "GDAL/GTiff"
59 MIMETYPE "image/tiff"
60 IMAGEMODE RGB
61 EXTENSION "tif"
62 END
63 LAYER
64 NAME "topo"
65 DATA "land_shallow_topo_8192.tif"
66 STATUS OFF
67 TYPE RASTER
68 END
69 LAYER
70 NAME "wcountry-line"
71 DATA "wcountry.shp"
72 STATUS OFF
73 TYPE LINE
74 CLASS
75 NAME "State Boundary"
76 STYLE
77 SYMBOL "line5"
78 COLOR 255 255 0
79 SIZE 1
80 END
81 END
82 END
83END
Files are changed as follows:#
Open the file: diff_mfa8_mfa6.html
Now our MapFile contains a new object OUTPUTFORMAT
. Within the
MAP
object defined by this object, and when used with the keyword
IMAGETYPE
.
Depending on the compiled library of MapServer, you can have a variety
of output formats to choose from - the GD library provides PNG
(8-bit and 24-bit), GIF
, JPEG
, WBMP
, the GDAL library,
which sources many of MapServer’s input formats, and can also provide
output in PNG
, JPEG
, TIFF/GeoTIFF
, and other raster formats;
the pdflib library provides PDF output.
Have a look at your MAPFILE object by changing the keyword IMAGETYPE
and experiment with OUTPUTFORMAT
. It should be used as
IMAGETYPE
value (eg: IMAGETYPE png
or PNG24 IMAGETYPE
), the
name of the output format.
Please consult the OUTPUTFORMAT
object reference:
//www.mapserver.org/mapfile/outputformat.html#outputformat