Skip to content

Commit

Permalink
Merge pull request #2274 from alicevision/dev/pixelRatioPreview
Browse files Browse the repository at this point in the history
[nodes] Blender: Rescale rendered images based on their pixel aspect ratio
  • Loading branch information
fabiencastan authored Dec 20, 2023
2 parents 17a5f65 + f6e961b commit 99ad7ad
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions meshroom/nodes/blender/scripts/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ def main():
setupRender(view, intrinsic, pose, args.output)
bpy.ops.render.render(write_still=True)

# if the pixel aspect ratio is not 1, reload and rescale the rendered image
if bpy.context.scene.render.pixel_aspect_x != 1.0:
finalImg = bpy.data.images.load(bpy.context.scene.render.filepath)
finalImg.scale(int(bpy.context.scene.render.resolution_x * bpy.context.scene.render.pixel_aspect_x), bpy.context.scene.render.resolution_y)
finalImg.save()
# clear image from memory
bpy.data.images.remove(finalImg)

# clear memory
if img:
bpy.data.images.remove(img)
Expand Down

0 comments on commit 99ad7ad

Please sign in to comment.