My question relates to the answer found at Exporting data frame as PNG in ModelBuilder using ArcMap
I've followed the steps in the answer provided by @PolyGeo, but my output PNG is just a blank image.
I also added a few extra lines of code from ExportToPNG example 2 here to control the size of the PNG, because by default it's 640 by 480 pixels:
https://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/exporttopng.htm
So my final code is:
import arcpy
lyrFile = arcpy.GetParameterAsText(0)
pngFile = arcpy.GetParameterAsText(1)
mxd = arcpy.mapping.MapDocument("D:/Old C Drive/School/Base Data/Scripts/Untitled.mxd")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
addLayer = arcpy.mapping.Layer(lyrFile)
arcpy.mapping.ExportToPNG(mxd, pngFile, df,
df_export_width=1920,
df_export_height=1080)
del mxd
My mxd is totally empty, so I'm not sure where I went wrong. I did see in the original question someone mentioned that using a blank document didn't work for them either so they used another mxd and it worked. I tried that but no luck.