1

In ArcGIS Pro (latest version), using the ExportToJPEG (or even ExportToPNG) arcpy function, I can't seem to export an image with my desired resolution. It always defaults to 96 dpi even when I specify 500. What am I doing wrong? Is this a bug?

This is the script I paste into the python console within ArcGIS Pro:

p = arcpy.mp.ArcGISProject("CURRENT")
print ("project loaded")
l = p.listLayouts("MyLayout")[0]
print ("layouts listed")
if not l.mapSeries is None:
 ms = l.mapSeries
 if ms.enabled:
   for pageNum in range(1, ms.pageCount + 1):
     ms.currentPageNumber = pageNum
     print("Exporting page {0} of {1}".format(str(ms.currentPageNumber), str(ms.pageCount)))
     l.exportToJPEG(r"C:\\Users\\Theo\\Dropbox\\site_plans\\Current_GR_site_plans\\GR2-GroundMovement-SP-_{0}".format(str(ms.currentPageNumber) + ".jpg", 500))

You can see at the end I specify 500 as the resolution. Even when I write- resolution = 500, it's the same. My images aren't coming out in my desired quality.

If I export a single page using the share ribbon, setting the dpi to 500, it works. But I'm automating this, so that's not a viable option for me.

Guides I've used:

https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fpro.arcgis.com%2Fen%2Fpro-app%2Farcpy%2Fmapping%2Fmapframe-class.htm

https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fpro.arcgis.com%2Fen%2Fpro-app%2Farcpy%2Fmapping%2Flayout-class.htm

similar issue to:

https://community.esri.com/thread/201455-exporttojpeg-resolution-problem

ExportToJPEG() arcpy script failure (ArcMap)

neither helped me.

2
  • sounds like a bug
    – artwork21
    Commented Sep 5, 2018 at 12:01
  • @artwork21 perhaps but it could also be something to do with how I'm referencing the layout in my script...?
    – Theo F
    Commented Sep 6, 2018 at 9:57

1 Answer 1

0

Syntax error, found on official ESRI website (they have been informed). Essentially, the last line has a closing bracket out of place. The line SHOULD read:

l.exportToJPEG(r"C:\\Users\\Theo\\Dropbox\\site_plans\\Current_GR_site_plans\\GR2-GroundMovement-SP-_{0}".format(str(ms.currentPageNumber)) + ".jpg", 500)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.