Why does mxd.makeThumbnail() generate a blurry thumbnail?

4098
8
05-27-2015 10:21 AM
MattCooper
Occasional Contributor

I am attempting to update thumbnails for a folder of MXD but the thumbnails generated in python are all blurry.  If I create the thumbnail using the map properties dialog inside arcmap the thumbnail is fine.  As an aside, the "make thumbnail" button is disabled in ArcCatalog.  Not sure if that is a bug or an issue with our install of 10.3 but it's the same on all our installs of 10.3.

Any ideas why the makeThumbnail method isn't producing high quality images?

Thanks!
Matt

0 Kudos
8 Replies
RebeccaStrauch__GISP
MVP Emeritus

I don't have a definitive answer, but I'm guessing that by default it is capturing the image at a particular zoom/scale.  If you're mxd is using a service with a cache, that might make sense since my guess is it would grab a cache and probably not do any on-the-fly rendering.

Just wondering, is there an option to specify the scale factor with python?

XanderBakker
Esri Esteemed Contributor
Any ideas why the makeThumbnail method isn't producing high quality images?

A thumbnail is not a high resolution image. The thumbnail becomes visible when opening a new session of ArcMap is started and the open mxd dialog is switched on. When I look at a thumbnail produced manually and a thumbnail produced with Python on a copy of the map document, it looks the same. It is still a small image of something like 134 * 93 pixels.

The fact that you say that you notice differences between the manually and by python produced thumbnails triggers me. Could you include a screen capture of this difference?

The thumbnail is created from the layout view of the map document. When you create the thumbnail with python, do you change the scale of the map before you create the thumbnail?

0 Kudos
MattCooper
Occasional Contributor

Sorry, I wasn't very clear when I said "high quality".  I'm not expecting anything but a thumbnail size image, but I did expect them to look the same if I generate them from arcpy or the ArcMap properties dialog.  I'll attach examples tomorrow that show the difference.  Here is the gist of what I'm trying to do.

import arcpy, time
mxd = arcpy.mapping.MapDocument("CURRENT")
basemapLayer = arcpy.mapping.Layer(r"\\psf\Home\Desktop\darkbasemap.lyr") 
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
arcpy.mapping.AddLayer(df, basemapLayer, "BOTTOM") 
df.scale = 73957191 #exact tile level. Added this after Rebecca mentioned the cache levels and resampling
arcpy.RefreshActiveView() # Added this when trying to solve the resolution issue
time.sleep(10) # Added this to see if pausing to allow for tiles to draw would help.  not sure if this does what I think...
mxd.makeThumbnail()
mxd.save()

The thumbnail is generated, but the thumbnail is very poor quality and not proportional, so it seems like it's more than just an issue of tiles being rendered before the thumbnail is generated, but maybe that is an incorrect assumption.

Thanks for the help!

Matt

0 Kudos
XanderBakker
Esri Esteemed Contributor

When you say proportional, what exactly do you mean with that? I have notices that when the layout is using a portrait page, the thumbnail only uses a small part of the thumbnail area.

Rebecca is right about that you get better results if the scale is equal to the nearest zoom level. However, you should experience the same behavior when exporting manually from ArcMap.

The code is creating a thumbnail for the current (open) map document. I thought you where creating thumbnails for all MapDocuments in a folder?

Really interested to see the differences between the manually and through Python generated thumbnails, since I haven't been able to reproduce this on my machine (ArcGIS for Desktop 10.3).

0 Kudos
MattCooper
Occasional Contributor

Hi Xander,

I mean that the python generated thumbnail is not maintaining the same aspect ratio as the ArcMap UI generated thumbnail.  This might be the main issue and not actually a resampling issue or change in the quality settings when generating the image. 

I changed the code to just work with a single mxd when I was trying to figure out why it didn't seem to be working and was just playing with the python window right in ArcMap. 

Here are a couple examples.  the Test2 image was generated from the ArcMap UI and Test1 was from python. Same exact layout in both.  Similar issues with portrait oriented MXD as well.  I saw there was a bug listed for the python methods for making/deleting thumbnails but it didn't mention this issue, but wondering if they are related cause sometimes the arcpy method just doesn't seem to work, especially if you try to run it again on the same MXD.

Thanks for the help!

Matt

Screen Shot 2015-06-02 at 11.04.29 AM.pngScreen Shot 2015-06-02 at 11.01.12 AM.png

0 Kudos
MattCooper
Occasional Contributor

oddly enough, I tried the exact same thing again today and they both appear to be generating the same thumbnail now.  No idea...

XanderBakker
Esri Esteemed Contributor

If I look at the thumbnail on the left I see an area of the US, while on the right I see what appears as Europe. It also seems to have a different spatial reference. This could cause the differences.

MattCooper
Occasional Contributor

Yeah, I noticed that as well after I posted.  There was a different spatial reference in the python one because it was set to albers equal area or something and didn't default to web mercator like the other when I added in the basemap.  Both mxd had no other layers in them.  I suppose it does make sense if one is projecting on the fly and causing issues with the thumbnail generation, but it's weird that it effects the entire thumbnail like that, instead of just having missing tiles in the dataframe.

I'll try again running this on an entire folder of MXD and see how it works if I make sure the spatial reference is set to web mercator.

Thanks for looking at this and taking the time to respond! Appreciate it.

Matt