newbie - using python to get the rendering resolution

Hi all,

I am new to this forum. I have been using Blender from time to time for a year or so, but I would like to use it from a shell to automate some scientific rendering. But, I need a way to determine the resolution of a blender file before I launch the blender renderer from the command line.

In other words, I need to be able to read in a .blend file, and obtain what the image resolution of that file is set to. I image I could use a python script for this? Any ideas that might be able to point me in the right direction. Or if another type of solution is better, please let me know.



The following code:

from Blender import *

sce = Scene.GetCurrent()
context = sce.getRenderingContext()
print "Image size = "+str(context.sizeX)+"x"+str(context.sizeY)

prints in the console the size of images that are to be rendered with the current settings.

The output is something like:

Image size = 800x600

Hope this helps! :wink:



That did the trick! Thanks for getting back to me. It was easier than I thought it would be to obtain the resolution image via the terminal. I have a script that calls [./blender -b file.blend -P] from the terminal so that my software will know in advance the size of image rendered by blender… piece of cake and thanks for your help.