1

So I have a script that uses the ArcPy module to create a series of PNGs. In particular I have an image that gets exported with a transparent background. The script runs great when I manually run it via CMD or IDLE. It also runs fine when I use the task scheduler with the security setting "run only when user is logged on". Using the task scheduler with this setting however, runs processes in the foreground (i.e. prompt pops up every ten min and stays for 30 seconds while script runs). When I use the security setting "run whether user is logged in or not", the prompt does not appear and the script executes, but output of one of the PNGs is not transparent, which makes running it in the background useless.

I've also tried using the "run with highest privileges" option and the "hidden" option with no luck.

Why would it work with certain settings, but not others? I just need this to run in the background.

Tyler
  • 201
  • 2
  • 6
  • My answer to the question [_When to use sys.path.append and when modifying %PYTHONPATH% is enough_](http://stackoverflow.com/a/4209102/355230) may have some bearing on yours since it involves running Python scripts with the task scheduler. – martineau Sep 24 '15 at 01:24
  • When you run it in a prompt, the paths (and environment) are loaded. You probably have some code that relies on that. – Burhan Khalid Sep 24 '15 at 01:25
  • I don't have any relative paths in the code and it runs fine in the task scheduler, it just doesn't export the PNG with transparency when it is run in the background. It all runs perfectly except it ignores the transparency parameter (rgb tuples): arcpy.mapping.ExportToPNG(mxd, localpath, '', 1056, 720, 96, False, "8-BIT_PALETTE", (255,255,255), (255,255,255)) – Tyler Sep 24 '15 at 01:31
  • What is `localpath`? – Burhan Khalid Sep 24 '15 at 01:32
  • Just a full filepath: r"J:\weather\graphics\conus\radar\2219.png" – Tyler Sep 24 '15 at 01:35

1 Answers1

0

After a few hours of searching for an alternative to windows task scheduler, it finally dawned on me to try the other image format that supports transparency, GIF. This retains transparency through the export and runs in the background.

arcpy.mapping.ExportToGIF(mxd, localpath, df_export_width=1056, df_export_height=720, resolution=96, transparent_color="255,255,255")

I still don't know why PNGs won't retain transparency when run (in background processing only) via windows task scheduler.

Tyler
  • 201
  • 2
  • 6