2

To render an image that is 1000px wide and 1500px high, I have to pass both variables from the command line:

povray scene.pov Width=1000 Height=1500      (or povray scene.pov +W1000 +H1500)

It would be much more practical to just write

povray scene.pov Width=1000      (or povray scene.pov +W1000)

and to have the height calculated based on the width in the script.

One might expect that the solution should look like this: #declare Height = 1.5 * Width;

But that does not work. (Povray does not know the variable Width.)
And defining Width and Height in the script does not change the output size. (Or anything else.)

(Using image_width and image_height does other terrible things, but does not change the render size either.)

Is there some way to achieve in the script what can be achieved from the command line?

(The point here is that I want to avoid the extra step of adding the correct size for a particular scene to the console command. Anything else that I would also have to copy to the console would not solve this initial problem. Having to copy the correct size or the correct factor is basically the same.)

Vadim Landa
  • 2,784
  • 5
  • 23
  • 33
Watchduck
  • 1,076
  • 1
  • 9
  • 29

2 Answers2

1

You can read the values set for output width and height from inside the script: those are in the pre-set variables image_width and image_height. Docs: https://www.povray.org/documentation/view/3.6.1/228/

Unfortunately, there is no way to set any of them from within the script - you can just check their value, and use them to set up camera parameters (for example, to get the correct aspect-ratio of the final image).

Also, check related question: POV-Ray: Setting output resolution or width/heigh ratio within the script \

(As it asks about the aspect ratio, this one is not a duplicate).

That said, the only way out seems to be to wrap the call to povray in another script that would calculate the parameters for you. Artisan's answer has asimple way to do that using Bash. A more sophisticated script could add more parameters, like one "aspect-ratio" that could improve what you can do.

jsbueno
  • 99,910
  • 10
  • 151
  • 209
0

If you are using Linux and bash your is your shell, you could add a bash function to your .bashrc:

function pov() {
  h=$(expr $2 \* 3 / 2)
  povray $1 +W$2 +H$h $3 $4 $5 $6 $7 $8 $9
}

If you enter

pov scene.pov 1000

it will execute:

povray scene.pov +W1000 +H1500

The first argument must be your .pov file, the second argument must be the width, without +W.

Artisan72
  • 3,052
  • 3
  • 23
  • 30
  • 1
    Yes, or I could just do it in one line: `width=1000; height=$(expr $width \* 3 / 2); povray scene.pov Width=$width Height=$height` But this is also not what I would call practical. I would like to know if this can be done in Povray. – Watchduck Mar 07 '21 at 18:13