Rendering a Camera Background Image As Simply As Possible

In Blender 2.91.0 I am trying to render a single image from one camera with a background image set for the camera. I’ve added a local image to use for my camera. It shows up in the 3D View when I view from that camera. Here’s my camera settings for the image:

In the Scene properties, I have Film set to Transparent.

I’ve seen various comments and answers about using a background image, but it’s confusing since things changed from 2.7x to 2.8. I’ve looked at this page for instructions on rendering the background image. It seems like a lot of work (especially for a newbie) to do for an image that I’ve just dropped in as a background image in the camera.

So if I have the background image imported in the camera, what’s the simplest way to get it to show up when I render from that camera?

Try unselecting transparent. Or maybe use import plane as image. You can add a background image to the scene world as well.

I don’t want to add a background to the entire image.

Eventually, what I’ll be doing is printing out blueprints and plans for the county Inspections Department and the contractors. I used to do this in 2D CAD, but there are a number of reasons for moving on to using Blender for it.

I’ll be setting up a number of cameras so when I make changes and it’s time to print, I can just render from each camera. If I have to keep changing settings from camera to camera, that leads to a lot of mistakes, so I really need the image to be associated with the camera.

I’ve tried selecting and unselecting transparent - that makes no difference. I’ll look into the import option and see what I can do there.

Thank you!

you can use this code snippet. Its not perfectly coded, but it gets the first background image from the active camera and create some compositor nodes, to make the camera background visible in rendering.

import bpy
import sys

# general settings
bpy.context.scene.render.film_transparent = True
bpy.context.scene.use_nodes = True
compositor = bpy.context.scene.node_tree


#get background image struct
active_cam = bpy.context.scene.camera.name
bg_images = bpy.data.objects[active_cam].data.background_images.items()

# get background image data, if it exists in struct
try:
    image = bg_images[0][1].image
    image_scale = bg_images[0][1].scale
except:
    sys.exit("No Background Found")


# create new compositor node, if it not already exists
node_names = {"bg_image_node":"CompositorNodeImage", "alpha_over_node":"CompositorNodeAlphaOver", "frame_method_node":"CompositorNodeScale", "scale_node":"CompositorNodeScale"}
current_nodes = compositor.nodes.keys()

for name,type in node_names.items():
    if name not in current_nodes:
        node = compositor.nodes.new(type=type)
        node.name = name
        

#edit compositor nodes  
bg_image_node = compositor.nodes["bg_image_node"]
bg_image_node.image = image

alpha_over_node = compositor.nodes["alpha_over_node"]
alpha_over_node.location[0] = 600

frame_method_node = compositor.nodes["frame_method_node"]
frame_method_node.space = "RENDER_SIZE"
frame_method_node.location[0] = 200

scale_node = compositor.nodes["scale_node"]
scale_node.inputs[1].default_value = image_scale
scale_node.inputs[2].default_value = image_scale
scale_node.location[0] = 400


#link compositor nodes
compositor.links.new(compositor.nodes["Render Layers"].outputs[0], alpha_over_node.inputs[2])
compositor.links.new(bg_image_node.outputs[0], frame_method_node.inputs[0])
compositor.links.new(frame_method_node.outputs[0], scale_node.inputs[0])
compositor.links.new(scale_node.outputs[0], alpha_over_node.inputs[1])
compositor.links.new(alpha_over_node.outputs[0], compositor.nodes["Composite"].inputs[0])

Sorry for it taking me a while to get back to you.

At this point, what I did was set things up so it prints out the views I want, then, outside of Blender, by working with the image it puts out, blending it with the desired background and saving the blended file. I’m going to have to go over what you are doing, since it might be a good way to do it.

I’m also considering changing it so an image can be put up almost against a camera, made invisible to other cameras (so it only shows up for that view). If I do that, I’d add something to make it easy to add text specifically on the plane of that added image. I want to get that done, since it’d make my life much easier, but it was a lot of work writing that first plugin. Most of the work was learning how to work with Blender from Python, so if I can figure out how to make my changes easily, I’m more likely to add that feature.