Image service ExportImage method
Exports an image in a well-known format (PNG, JPEG, etc.) for a given image description.
ExportImage(GeoImageDescription ImageDescription, ImageType ImageType)
Parameter |
Description |
---|---|
ImageDescription |
Defines the properties of the image generated by the service. Pixel data will be processed on-the-fly to fit description properties. The properties you can specify include extent, spatial reference, compression, interpolation, band selection, etc. ImageDescription also defines a mosaic rule on how mosaic should be performed, and a rendering rule on how the image should be rendered using a MosaicRule and a RenderingRule value objects. |
ImageType |
Defines the format and the return type for transmitting the requested image. |
Return Value
An ImageResult object.
Remarks
The supported formats, defined using the ImageType parameter, include JPEG, PNG, BMP, and TIFF. The JPEG format is the same as the JPEG compressed image returned from the GetImage method. Image content can be returned as a URL or as a MIME data stream.
If the size of the image in terms of number of columns and rows exceeds the limit defined in the image service configuration, this method will return an error. If the pixel type defined in ImageDescription is different from the pixel type of the image service, the pixel values will be converted according to the specified pixel type if possible.
If the image service pixel type cannot be converted to the requested pixel type, a default raster renderer will be applied. A proper default renderer is created using the same rule as when a raster dataset of the same properties, e.g. number of band, pixel type, etc. is added to map. "JPGPNG" format returns a JPG when there are no transparent pixels and otherwise PNG.
Examples
C#
//define image server
string url_DEMService = "http://ais3/arcgis/services/testDEM/ImageServer";
testDTED_ImageServer imageSrv = new testDTED_ImageServer();
imageSrv.Url = url_DEMService;
//define image description
GeoImageDescription geoImgDesc = new GeoImageDescription();
geoImgDesc.Height = 600;
geoImgDesc.Width = 800;
geoImgDesc.Interpolation = rstResamplingTypes.RSP_BilinearInterpolation;
ImageServiceInfo isInfo = imageSrv.GetServiceInfo();
geoImgDesc.Extent = isInfo.Extent;
//define a hillshade function and attach to a rendering rule
RenderingRule renderRule = new RenderingRule();
HillshadeFunction function = new HillshadeFunction();
HillshadeFunctionArguments argument = new HillshadeFunctionArguments();
argument.Names = new string[] { "Altitude", "Azimuth", "ZFactor" };
argument.Values = new object[] { 45, 315, 1.0 };
renderRule.Arguments = argument;
renderRule.Function = function;
renderRule.VariableName = "DEM";
geoImgDesc.RenderingRule = renderRule;
//define export format
ImageType imageType = new ImageType();
imageType.ImageFormat = esriImageFormat.esriImageJPG;
imageType.ImageReturnType = esriImageReturnType.esriImageReturnURL;
ImageResult result = imageSrv.ExportImage(geoImgDesc, imageType);
//download result
string fileName = @"c:\temp\hillshadeFunction.jpg";
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.DownloadFile(result.ImageURL, fileName);
Java
String serviceURL = "http://localhost:6080/arcgis/services/ImageService/ImageServer";
ImageServerBindingStub imageService = new ImageServerBindingStub(serviceURL);
//Get GeoImageDescription
GeoImageDescription geoImgDesc = new GeoImageDescription();
//Setup extent
ImageServiceInfo serviceInfo = imageService.getServiceInfo();
EnvelopeN extent = (EnvelopeN)serviceInfo.getExtent();
geoImgDesc.setExtent(extent);
geoImgDesc.setHeight(600);
geoImgDesc.setWidth(800);
//Setup imagetype
ImageType imageType = new ImageType();
imageType.setImageFormat(EsriImageFormat.esriImageJPG);
imageType.setImageReturnType(EsriImageReturnType.esriImageReturnURL);
//Export image
ImageResult imageResult = imageService.exportImage(geoImgDesc, imageType);
System.out.println("Image URL: " + imageResult.getImageURL());