Sub topic 9
Render resolution and aspect ratio
This chapter assumes you can add a camera, make it the active scene camera, and know that focal length and sensor size set the field of view. It covers what the Output properties do to the camera's frame, and how they change what the camera sees.
What resolution controls
Render resolution is the size of the final image in pixels. It lives on the scene, not on the camera, and every camera in the scene shares it. You set it in Properties > Output > Format.
Four values define the output:
- Resolution X and Resolution Y are the width and height in pixels.
- Resolution % scales both dimensions at render time. The stored X and Y values do not change.
- Pixel aspect X/Y describes the shape of a single pixel. It is 1:1 for almost all modern work.
The aspect ratio of the frame is width divided by height, adjusted by the pixel aspect:
aspect = (resolution_x * pixel_aspect_x) / (resolution_y * pixel_aspect_y)At 1920 x 1080 with square pixels, that is 1.778, or 16:9. The camera view in the viewport is a rectangle with exactly this shape. The rectangle changes when you change the resolution, even if you never touch the camera.
Setting resolution with bpy
The script below creates a camera if the scene has none, sets a resolution, and prints the result. You can paste it into Blender's Text Editor and run it.
import bpy
scene = bpy.context.scene
if scene.camera is None:
cam_data = bpy.data.cameras.new("ShotCamera")
cam_obj = bpy.data.objects.new("ShotCamera", cam_data)
scene.collection.objects.link(cam_obj)
scene.camera = cam_obj
render = scene.render
render.resolution_x = 1920
render.resolution_y = 1080
render.resolution_percentage = 50
render.pixel_aspect_x = 1.0
render.pixel_aspect_y = 1.0
aspect = (render.resolution_x * render.pixel_aspect_x) / (
render.resolution_y * render.pixel_aspect_y
)
out_w = render.resolution_x * render.resolution_percentage // 100
out_h = render.resolution_y * render.resolution_percentage // 100
print(f"Aspect ratio: {aspect:.3f}")
print(f"Rendered size: {out_w} x {out_h} px")With Resolution % at 50, this prints a rendered size of 960 x 540. Use a lower percentage for test renders. Because it keeps the aspect ratio and the framing, a 25% or 50% preview shows the same composition as the final render, at a fraction of the time.
Common formats
Choose the aspect ratio first, because it decides the composition. Choose the pixel count second, because it only decides the sharpness.
| Use | Resolution | Aspect ratio |
|---|---|---|
| HD video | 1920 x 1080 | 16:9 |
| 4K UHD video | 3840 x 2160 | 16:9 |
| Square social post | 1080 x 1080 | 1:1 |
| Portrait social post | 1080 x 1350 | 4:5 |
| Vertical video | 1080 x 1920 | 9:16 |
| Widescreen cinema | 2048 x 858 | about 2.39:1 |
The Format panel also has a preset menu with common video sizes. Presets only fill in the numbers above, so you can still edit them afterward.
How aspect ratio interacts with sensor fit
A camera has one sensor width, 36 mm by default. The frame has two dimensions, so Blender needs a rule for which dimension the sensor width applies to. That rule is Sensor Fit:
- Auto applies the sensor size to the larger dimension of the frame.
- Horizontal always applies it to the width.
- Vertical always applies it to the height.
With Auto, the field of view along the longer side is fixed by focal length and sensor size, and the shorter side follows from the aspect ratio. Take a 50 mm lens on a 36 mm sensor:
- At 1920 x 1080, the horizontal field of view is 39.6° and the vertical is 22.9°.
- At 1080 x 1080, both are 39.6°.
- At 1080 x 1920, Auto applies the sensor to the height, so the vertical field of view is 39.6° and the horizontal is 22.9°.
You can read these values from the camera data with angle_x and angle_y. Both are in radians.
import math
import bpy
scene = bpy.context.scene
cam_data = scene.camera.data
cam_data.lens = 50
cam_data.sensor_width = 36
cam_data.sensor_fit = 'AUTO'
for size in ((1920, 1080), (1080, 1080), (1080, 1920)):
scene.render.resolution_x, scene.render.resolution_y = size
bpy.context.view_layer.update()
h = math.degrees(cam_data.angle_x)
v = math.degrees(cam_data.angle_y)
print(f"{size[0]}x{size[1]}: horizontal {h:.1f} deg, vertical {v:.1f} deg")The practical effect is that changing the resolution from landscape to portrait with Auto fit does not zoom the image. It rotates the same-sized field of view so the long side keeps the same angle. Set Sensor Fit to Horizontal if you want the horizontal field of view to stay fixed regardless of the frame shape. This suits cases such as keeping the width of a product shot while trying several aspect ratios.
Changing the aspect ratio mid-project
Changing the aspect ratio after you have framed a shot usually breaks the composition. Widening from 4:3 to 16:9 with Auto fit keeps the horizontal field of view and cuts the top and bottom. A subject that filled the height now has less room above and below it.
A sound workflow is:
- Decide the delivery format before you place the camera.
- Set the resolution first, then position and aim the camera.
- If you must change the ratio later, re-check the framing in camera view and adjust the camera position or focal length.
If you need several formats from one scene, you can create one camera per format. Each camera can use a different Sensor Fit. The resolution itself is scene-wide, so you change it between renders or in a script.
Border rendering
Render Region limits the render to a rectangle inside the frame. You set it in the viewport with Ctrl+B in camera view. The region is stored as fractions of the frame, so it follows resolution changes.
import bpy
render = bpy.context.scene.render
render.use_border = True
render.border_min_x = 0.25
render.border_max_x = 0.75
render.border_min_y = 0.25
render.border_max_y = 0.75
render.use_crop_to_border = FalseWith use_crop_to_border off, the output keeps the full frame size and only the region is rendered. The rest is transparent or empty. With it on, the output image shrinks to the region, which changes the output size and the aspect ratio of the saved file. This option is a common surprise when a rendered file does not match the resolution you set.
Checking the frame in camera view
In camera view, Blender draws the frame as a rectangle. The area outside it is dimmed by the passepartout. A later chapter covers passepartout and lens shift in detail. For this chapter, remember that the visible frame always matches the output aspect ratio. If it does not look right, the cause is the resolution, the pixel aspect, or a render region. It is not the camera.
You can turn on the thirds overlay for judging composition:
import bpy
cam_data = bpy.context.scene.camera.data
cam_data.show_composition_thirds = True
cam_data.show_passepartout = True
cam_data.passepartout_alpha = 0.8Common errors
- The render has the wrong shape. The scene resolution is shared by all cameras. Check Output properties, not the camera settings.
- The framing changed after a resolution edit. Sensor Fit and the new aspect ratio changed the field of view on one axis.
- The output file is smaller than expected. Either Resolution % is below 100, or Crop to Border is on with an active render region.
- Pixels look stretched. Pixel aspect is not 1:1. Reset it unless you are making footage for a non-square-pixel format.
- A preview looks right but the final render is cropped. The viewport can show a different region than the final output if you left a render region enabled.
Exercise
A scene uses a 50 mm lens, a 36 mm sensor width and Sensor Fit set to Auto. The resolution changes from 1920 x 1080 to 1080 x 1920. What happens to the horizontal and vertical field of view, and which setting would keep the horizontal field of view at 39.6°?
Show answer
At 1920 x 1080 the horizontal field of view is 39.6° and the vertical is about 22.9°. At 1080 x 1920, Auto applies the sensor width to the larger dimension, which is now the height, so the vertical field of view becomes 39.6° and the horizontal drops to about 22.9°. Setting Sensor Fit to Horizontal keeps the horizontal field of view at 39.6° in both cases.