I am using Execute Task (Export Web Map Task) to export an image. js is 4.12. If format is PNG32, the file size is 378k which is rather large for a 400x400 image at 96 dpi. The file size should be closer to 140k. I tried switching to JPG which took the size down to 317k. If I include compressionQuality to operationalLayers there is no change in size. How do I get the image size smaller?
This is a sample request
{"mapOptions":{"showAttribution":false,"extent":{"xmin":479389.87880438194,"ymin":1159369.4997793399,"xmax":479840.91235113516,"ymax":1159594.2281684615,"spatialReference":{"wkid":102659}},"spatialReference":{"wkid":102659},"rotation":0},"operationalLayers":[{"opacity":1,"minScale":0,"maxScale":0,"format":"jpg","compressionQuality":50,"url":"https://www.mymanatee.org/arcgis01/rest/services/basemap/aerials/MapServer"},{"opacity":1,"minScale":0,"maxScale":0,"url":"https://gis.manateepao.com/arcgis/rest/services/Website/WebLayers/MapServer"},{"opacity":1,"minScale":0,"maxScale":0,"url":"https://gis.manateepao.com/arcgis/rest/services/Website/WebLayers/MapServer","layers":[{"id":1,"layerDefinition":{"drawingInfo":{"renderer":{"type":"simple","symbol":{"type":"esriSFS","style":"esriSFSNull","outline":{"type":"esriSLS","style":"esriSLSSolid","color":[66,244,206],"width":3}}}},"source":{"type":"mapLayer","mapLayerId":1},"definitionExpression":"PARID='1014100000'"}}]}],"exportOptions":{"outputSize":[400,400],"dpi":96}}
Solved! Go to Solution.
Using the PNG8 format for the image cuts the file size roughly in half. Some other things to tweak are lowering the opacity or increasing the dpi. The second two do decrease file size, but only slightly.
As far as I can tell, the compressionQuality property only applies when working with an ImageServer. Is there a reason why you need a smaller file size?
References:
Export Image—ArcGIS REST API: Services Directory | ArcGIS for Developers
I'm generating and saving them. The diskspace it's costing us could be halved if the average image size was 150k.
Using the PNG8 format for the image cuts the file size roughly in half. Some other things to tweak are lowering the opacity or increasing the dpi. The second two do decrease file size, but only slightly.
Thanks. Changing to PNG8 reduced the image size by 65% without any obvious change in quality.
PNG8 117k
PNG32 331k
Gregory,
The major difference in PNG8 and PNG32 is that PNG32 supports alpha channel (i.e transparency).
Thanks, Robert. I didn't know that. Can you give me an example for why I would need transparency?
If you needed to overlay that image on top of another image.