PNGFormat
Summary
The PNGFormat object represents a collection of Portable Network Graphics (PNG) file properties that can be configured and used with the export method on the Layout, MapFrame, MapView, MapSeries and BookmarkMapSeries objects to create an output PNG file.
Discussion
PNG is a versatile raster format that can be displayed in web browsers and inserted into other documents. It supports high-bit-depth color and uses a lossless compression. For maps, PNG is often the best raster format, since the lossless compression keeps text and line work legible by preventing the compression artifacts that can occur in JPEG format. PNG files can also define a transparent color; part of the image can be displayed as transparent in a web browser, allowing backgrounds, images, or colors to show through. PNGs can be generated with an accompanying world file for use as georeferenced raster data.
The createExportFormat method can be used to create a PNGFormat object if the format parameter is set to PNG. The returned PNGFormat object contains all the properties associated with a generating a PNG file. These properties can be modified accordingly to produce different output results.
Properties
| Name | Explanation | Data type |
|---|---|---|
|
clipToElements (Read and Write) |
If set to |
Boolean |
|
colorMode (Read and Write) |
A string constant that represents the number of bits to describe color in a pixel. The default value is
|
String |
|
filePath (Read and Write) |
A string that represents the system path and file name, including the extension, for the exported file. |
String |
|
geoReferenceMapFrame (Read and Write) |
The MapFrame used to control the coordinate system when the |
MapFrame |
|
height (Read and Write) |
The height, in pixels, of the map area to be exported. This property only applies when exporting a |
Double |
|
resolution (Read and Write) |
The effective dpi of the output vector data. The default value is 96. Note:When exporting a |
Integer |
|
showSelectionSymbology (Read and Write) |
Show selected features in the map or map frame as selected in the output file. Setting this value to |
Boolean |
|
threshold (Read and Write) |
Image intensities set above this value will appear white in the output file and all other values will appear black. This property is applied only when the |
Boolean |
|
transparentBackground (Read and Write) |
If set to Note:Transparent backgrounds are only supported when |
Boolean |
|
width (Read and Write) |
The width, in pixels, of the map area to be exported. This property only applies when exporting a |
Double |
|
worldFile (Read and Write) |
If set to |
Boolean |
Methods
setColorMode(color_mode)
A string constant that represents the number of bits to describe color in a pixel.
| Name | Explanation | Data type |
|---|---|---|
|
color_mode |
Below is a list of valid strings.
|
String |
Code sample
The following script exports a layout to PNG format using default property values.
p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
png = arcpy.mp.CreateExportFormat('PNG', r'C:\Temp\Output.png')
lyt.export(png)