Select to view content in your preferred language

exporting Jpegs with ptyhon

3498
10
Jump to solution
07-15-2014 04:03 AM
jackwalker
Deactivated User

We are in the process of migrating from One sever to another. But that is another story i am working as Gis Tech , because of the migration we have a lot of MXD file and we need to see which ones need to be kept. Because the maps take such a long time to load and there are so many i thought that it be better to have a jpeg for each ,map which i can consult with the technical guys , on wheather we need to keep it or not.

I am going into the manually at the moment and then exporting out a Jpeg.

i was wondering if  there is a script kicking around for something like this ? Ideally i like the script to look in a folder and any sub folders , then export out the existing layout view as a Jpeg , using the filename of the existing map and save it into a pre defined folder ?

How long would a script like this take . Would it be faster than the time its taking to open the MXD S , which is 3- 5 minutes for each one

Thanks a lot Jak

!

1 Solution

Accepted Solutions
ChristopherMoravec1
Deactivated User

Jack,

I put together a quick script that does this just this morning!  I am doing it for PDF, but you can easily do it for JPEG as well.  Just for kicks I went ahead and converted this into a PYT file.  You should be able to take this file and open it in ArcMap like any toolbox tool (as long as you are using 10 or higher).  All you need to do is specify the folder and then the type of export you want, in your case JPEG and let it go.  It generates the JPEGs in the same folder as the MXD and with the same name.  You can change that around though.  Check it out here: An extension of export_mxd.py that provides an ESRI toolbox that does the same thing as the export_m...

I have also attached the pyt file for you.  It should behave just like a normal toolbox once you download it, just browse to it in the catalog view of your ArcGIS for Desktop and double click on the tool in the toolbox.  Specify the folder path you want, and the type of export.

Christopher

View solution in original post

10 Replies
JohnReiser
Occasional Contributor

You should be able to do the following:

Writing something like this should not take long. This will not check to see if the data frames have unbroken links, but if you know all of your MXDs are good to go, that shouldn't be a problem.

0 Kudos
jackwalker
Deactivated User

Thanks for the Reply.

i have been able to find this

Batch Export And Print Script/Tool stopped working in 10.2

i do not really have much experience of Running Python Scripts . Any ideas on how to get this one going. I tried to save it as a script and then add it to my Tool box , but when i ran it it says there is no parameters related with the tool.

i cannot see where to put my input folder > Any have any ideas i m probably missing something simple.

Thanks

0 Kudos
JohnReiser
Occasional Contributor

When you add a script, you'll need to define those parameters. It looks like that scripts accepts a MultiValue of files, some booleans for the desired actions (save as AI, printing, etc) and then an output folder and another boolean for merging the files into one PDF. You can configure that yourself from within the Script's properties within your Toolbox.

If you're more comfortable with ModelBuilder, you could use what this person outlined here: arcgis 10.0 - How to export data frame as PNG in ModelBuilder? - Geographic Information Systems Stac...

If you need a place to start for learning or getting a refresher on both Python and ModelBuilder, I have some resources that I've put together that are free:

Naturally, the ESRI courses for Python are a great resource, too:

0 Kudos
jackwalker
Deactivated User

Cheers John for the links ,those are some good places to start , thanks

0 Kudos
ChristopherMoravec1
Deactivated User

Jack,

I put together a quick script that does this just this morning!  I am doing it for PDF, but you can easily do it for JPEG as well.  Just for kicks I went ahead and converted this into a PYT file.  You should be able to take this file and open it in ArcMap like any toolbox tool (as long as you are using 10 or higher).  All you need to do is specify the folder and then the type of export you want, in your case JPEG and let it go.  It generates the JPEGs in the same folder as the MXD and with the same name.  You can change that around though.  Check it out here: An extension of export_mxd.py that provides an ESRI toolbox that does the same thing as the export_m...

I have also attached the pyt file for you.  It should behave just like a normal toolbox once you download it, just browse to it in the catalog view of your ArcGIS for Desktop and double click on the tool in the toolbox.  Specify the folder path you want, and the type of export.

Christopher

jackwalker
Deactivated User

Hi Christopher ,

That is great that is excatly the kind of thing that i was looking for , it works really well .

i am not sure how hard or easy it would be to make a slight modification. On some of the maps that i have there are several book marks which so different lay out.

i was wondering how easy it would be to incorprate this into your tool.

i found a thread down here related to this , i was wondering how difficult would it be to incorprate this into your tool

Accessing a Map Documents Bookmarks through Python and ArcPy

Thanks again for your help , that tool works great ‌

0 Kudos
ChristopherMoravec1
Deactivated User

Jack,

Yeah it is possible.  A simple version is not too hard (I have updated the code) but it does start to get complicated with different data frames and different bookmarks.  So, that said, what I made it do is export each data frame, with each bookmark that applies to it.  The file names are calculated based on the name of the data frame and the bookmark.  I have attached the tool and have updated the gist at: An extension of export_mxd.py that provides an ESRI toolbox that does the same thing as the export_m...

I will add this to my library (pzpy) when I have some time after the UC.  You can check it out here: http://pzpy.guru

Christopher

jackwalker
Deactivated User

Thanks Christopher , thats amazing thanks very much i have not had a chance to try it out , but i m sure thats going to work prefectly.  Your a star

0 Kudos
ChristopherMoravec1
Deactivated User

Glad I could help!  Let me know if you ever need anything else!

0 Kudos