< Day Day Up > |
10.3. Setting Output Image FormatsMapServer can produce map images, legends, and scale bars in different image formats. Throughout this chapter, the PNG format is shown in the examples because it is the default image format. MapServer packages can have different default image formats. PNG format is commonly supported by many MapServer packages, but in some cases MapServer may not be able to produce PNG files or doesn't produce them by default.
The output image format can be explicitly set in the map file. This requires adding a single line specifying the output format you are requesting. Example 10-11 shows the additional line added to the earlier example map file. Example 10-11. Specifying the output image format as JPEG
This setting can be overridden when using the shp2img command with the -i option. It can't be overridden when using commands such as scalebar or legend, as mentioned earlier in "Creating Your First Map Image." The IMAGETYPE specified must be one supported by the MapServer package you are running. To check what output formats your installation supports, run the mapserv file (or mapserv.exe on Windows) with the -v option. This option tells you what input and output formats are supported by the utilities in your MapServer package. The following example shows the output from the MapServer used in this chapter, with the output image formats highlighted:
This listing shows that this installation of MapServer can only output PNG, JPEG, or WBMP format files. That means the IMAGETYPE could be set to either of those three. Therefore it can't output GIF, TIFF, PDF, or any other formats.
For many vector-mapping applications, the PNG output format is sufficient. In many cases it will be the default output format. If you have a raster layer with more than 256 colors, it will probably not look right using the default PNG image type. Usually, all that is needed is to increase the depth of colors that MapServer creates in the output image. This can be set by requesting a 24-bit version of the PNG output format such as:
Be warned: increasing the color depth also increases the file size of your images. This can be a major performance issue when sending graphics across the web. More specific output image format settings can be made using an OUTPUTFORMAT object in your map file. This is an advanced topic and isn't described here. Please refer to the MapServer documentation at http://mapserver.gis.umn.edu/doc/mapfile-reference.html#outputformat. |
< Day Day Up > |
No comments:
Post a Comment