Legend fonts get messed up saving screenshot using pvpython

Dear All,

I am using the latest paraview binary (version 5.8.0 with MPI and python 3) under Linux.

I have a simple python script (recorded via set trace) which loads a XDMF file, plots the data, adds a colorbar (setting font size to 12) and then saves a screenshot. If I run that script in the GUI I get the desired result.

However if I run the same script in a terminal via

pvpython trace.py

the font size is messed up:

Can someone point out what I’m doing wrong?

Thanks,
Philipp

Make sure you set the view size to the same size as you image with something like:
view.ViewSize = [1024, 1024]

if your image is 1024 x 1204 pixels. I think there is something like this commented out in your script produced by the trace.

Thank you for that quick response!

Hello Dan,
I am experiencing now some limitations regarding the image size. I now use the name of the resulting PNG and pixels as input arguments. E.g. with the view size you suggested:

pvpython script.py screenshot.png 1024 1024

For large sizes this happens:

Why is it 1920 x 1136 for another.png?

You should not go higher than your screen size.

@danlipsa That’s not true. You absolutely can go bigger than your screen size, I believe up to the size of your frame buffer. That’s the way you make good resoltuion images for powerwalls. If there IS an issue making big images, that is a bug and needs to get fixed.

2 Likes

The original question, about Color Legend font size changes between gui and batch is a bug. Written up here: https://gitlab.kitware.com/paraview/paraview/-/issues/19831. @pdiercks - Thanks for reporting. Alan

I played around with the second question, having to do with larger resolutions. I am on a very small viewport, about 700x300 (i.e., macbook, working remotely). I created .png’s that were 2345X1234 successfully, both with ParaView, and pvbatch from a script. Note that due to the file format for .png’s, what actually comes out in both cases is 2345X1232. I also did find one case where there was a 2 pixel wide difference, but don’t see that as an issue.

@wascott thank you for your answers. Regarding larger resolutions It seems there is a difference between pvpython and pvbatch.

Alan,
You are right, you can save an image larger than the screen size. I was referring to setting the view size when rendering on-screen that does limit you to the size of the screen - which seems to be happening for pvpython.

But I don’t know why there is a difference between pvbatch and pvpython.

Philip, do you see a window created on the screen for rendering? For both pvpython and pvbatch?

They look the same to me. What I did:

  • Linux, 5.8.0, builtin server.
  • Create a trace
  • Sources Fast Uniform Grid. Color by something. Solid.
  • Save screenshot at 2345x1234
  • Stop Trace.
  • Save this screenshot
  • Run trace with pvbatch. Save this screenshot
  • Run trace with pvpython. Save this screenshot.

Using display on Linux, Info, I looked at picture resolution. Both were the same. (2345x1232).

Here is using Identify:
Dir$ identify deleteMeC-pvbatch.png
deleteMeC-pvbatch.png PNG 2345x1232 2345x1232+0+0 8-bit DirectClass 213KB 0.000u 0:00.000
Dir$ identify deleteMeC-pvpython.png
deleteMeC-pvpython.png PNG 2345x1232 2345x1232+0+0 8-bit DirectClass 213KB 0.000u 0:00.000

If this is still a bug, please provide very clear directions, along with a python script, how to replicate.

Hello @wascott,

I went through the your steps above and can confirm that there’s no difference between pvpython and pvbatch using the trace as above.

I think the problem was that I confused view size and PNG resolution.

When setting a specific view size like

# uncomment following to set a specific view size
renderView1.ViewSize = [2345, 1234] # bigger than screen size

it seems that pvpython is limited to the screen size as @danlipsa suggests. (For pvpython a window is created but for pvbatch there is not).

Steps

  • Start Trace
  • Sources > Data Objects > Fast Uniform Grid
  • Surface
  • Color by Distance Squared
  • Save screenshot at 2345 x 1234
  • Stop Trace
  • Edit renderView1.ViewSize as above
  • Save the script as trace.py
  • Run pvpython trace.py, save this screenshot
  • Run pvbatch trace.py, save this screenshot

Thanks,
Philipp

Philip,
You’ll need to set the view size the same as the image size only for pvbatch. For pvpython you don’t need to do that - this will take care of the window bigger than the screen size problem.

I just tried that and it works fine.

Hello everyone,

I am using Paraview 5.8.1 and I am facing the same issue.

I am setting the ImageResolution parameter the same as the ViewSize parameter but when I run the script through pvbatch the size of the legend becomes larger than it should be?

Can somebody help?

Regards,
Rui

Upgrade to ParaView 5.10.0? https://gitlab.kitware.com/paraview/paraview/-/issues/19831.

Thank you for the suggestion. I have tried version 5.9.0 and it seems to work properly. I will also consider the most recent version.