GregNash
GregNash

Reputation: 1336

In Python script for Paraview, can I specify the resolution when I do a SaveScreenshot()?

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?

Upvotes: 3

Views: 2410

Answers (2)

GregNash
GregNash

Reputation: 1336

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.

Upvotes: 2

Cory Quammen
Cory Quammen

Reputation: 1263

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.

Upvotes: 4

Related Questions