3

When working ParaView's gui, I can click File > Save Screenshot to create a .png file of my work. With this procedure, I can specify whatever resolution that I want. I want to automate the generation of screenshots in a python script, but I don't see a way of specifying a resolution. Is this possible? I've tried

myRenderView.ViewSize = [1000, 1000]

which has some sort of effect, but not the desired one.

Looking at the source code for SaveScreenshot() I see that a servermanager.ParaViewPipelineController() object is created and then its WriteImage() method is called. I was thinking that maybe this WriteImage() method has resolution arguments that are not a part of the wrapper's arguments, but I can't find the definition of that method. I haven't tried downloading/compiling the actual ParaView source code. I'm just searching around online.

Maybe I should be using vtk directly instead of trying to work through ParaView?

GregNash
  • 1,316
  • 1
  • 16
  • 25
  • have you tried the magnification argument? http://www.paraview.org/ParaView3/Doc/Nightly/www/py-doc/paraview.simple.html?highlight=save#paraview.simple.SaveScreenshot – lib Aug 11 '15 at 07:18
  • No, I haven't. I want to change the resolution in a way that will change the aspect ratio of the image produced. For example, instead of producing the 2470 x 1714 plots that are being created by my code now, I'd like to make one that is 2000 x 2000 pixels. – GregNash Aug 11 '15 at 12:59

2 Answers2

4

I think the ViewSize parameter needs to be able to fit within the resolution of your monitor.

Try this in your script:

renderView1.ViewSize = [400, 400]
SaveScreenshot('image.png', magnification=5, quality=100, view=renderView1)

This should yield your desired image size.

Cory Quammen
  • 1,243
  • 7
  • 9
  • 1
    I just played with it and found that ViewSize doesn't need to be smaller than the monitor resolution. However, I saw an interesting pattern while I was playing. I set ViewSize to [400, 400] and got images of [416, 438]. Then, when I set ViewSize to [2000, 2000] I got images of [2016, 2038]. – GregNash Aug 14 '15 at 15:21
2

You have to subtract [16, 38] from your desired resolution then set the ViewSize parameter. To get an image that is 1000 x 1000 pixels, use:

myRenderView.ViewSize = [984, 962]
SaveScreenshot('image.png', magnification=1, quality=100, view=myRenderView)

To get an image that is 2000 x 2000 pixels, use:

myRenderView.ViewSize = [1984, 1962]
SaveScreenshot('image.png', magnification=1, quality=100, view=myRenderView)

Alternatively, you could change the magnification like this

myRenderView.ViewSize = [984, 962]
SaveScreenshot('image.png', magnification=2, quality=100, view=myRenderView)

to get a 2000 x 2000 pixel image. This choice will change the size of the orientation axes.

GregNash
  • 1,316
  • 1
  • 16
  • 25