# How to copy background images from one .blend to another?

I have a bunch of background images in one .blend, and I'd like to "append" (or link if that's possible) them into other .blends.

I couldn't find anything in the append tree for appending background images; I can append the just the image datablocks from the image tree, but seemingly not the background image entries.

Is there any way to copy the background image entries, not just the images themselves?

Coming up against the same thing I wrote some scripts many moons ago, with the idea of making it an addon. Only got this far, I've updated to handle clips.

Run this script in the blend file with bg images set up. It adds a set of properties onto the images mirroring the background image settings, & also the name of the screen the 3D view is in. (Doesn't discern for multi 3d views in same screen).

import bpy

context = bpy.context
text = bpy.data.texts.get("BGImages.py")
if text is None:
text = bpy.data.texts.new("BGImages.py")

text.clear()

spaces = [space for screen in bpy.data.screens
for a in screen.areas if a.type == 'VIEW_3D'
for space in a.spaces if space.type == 'VIEW_3D' if len(space.background_images)]

for s in spaces:
text.write("#Screen: %s\n" % s.id_data.name)
for i in s.background_images:
text.write("#%s\n" % ("-"*72))
for p in i.bl_rna.properties.keys():
if p in ['rna_type', 'image_user', 'clip_user']:
continue
val = getattr(i, p)

text.write("i.%s = " % p)
text.write("%s\n" % repr(val))

if not val:
continue
if i.source == 'IMAGE':
i.image["screen"] = s.id_data.name
if type(val).__name__ in ["bool", "str", "float", "int"]:
i.image[p] = val
else:
i.clip["screen"] = s.id_data.name
if type(val).__name__ in ["bool", "str", "float", "int"]:
i.clip[p] = val


It creates a text file named BGImages.py, ( ultimately making this a script to link / append then run and import, was the idea 8^)

#Screen: Scripting
#------------------------------------------------------------------------
i.source = 'IMAGE'
i.image = bpy.data.images['getting_started.blend2.png']
i.clip = None
i.offset_x = 0.0
i.offset_y = 0.0
i.size = 10.0
i.rotation = 0.0
i.use_flip_x = False
i.use_flip_y = False
i.opacity = 0.5
i.view_axis = 'ALL'
i.show_expanded = True
i.use_camera_clip = True
i.show_background_image = True
i.show_on_foreground = False
i.draw_depth = 'BACK'
i.frame_method = 'STRETCH'


Now in your new file if you link / append the bg images & run this script

import bpy

images = [i for i in bpy.data.images if "screen" in i.keys()]
clips = [i for i in bpy.data.movieclips if "screen" in i.keys()]
dic = {}
images.extend(clips)

for i in images:
l = dic.setdefault(i["screen"], [])
l.append(i)

def gonk(self, context):
space = context.area.spaces.active
for i in dic.setdefault(context.screen.name, []):
print(i.name)
bi = space.background_images.new()
if i["source"] == 'IMAGE':
bi.image = i
else:
bi.clip = i
for k in i.keys():
if k in ["screen", "image", "clip"]:
continue
setattr(bi, k, i[k])

def bgimages(self, context):
layout = self.layout
screen = context.screen
l = dic.setdefault(screen.name, [])
layout.enabled = len(l) > 0
layout.prop(context.screen, "toggle", toggle=True, text="%s (%d)" % (screen.name, len(l)))

bpy.types.Screen.toggle = bpy.props.BoolProperty(update=gonk)
bpy.types.VIEW3D_PT_background_image.append(bgimages)


You will see a button which tells me that two images in the Scripting screen 3DView can be added to the backround images of this 3D view in the Scripting screen of my new file. You will need to change the screen name to match the screen name of the original file.

All the background images are stored in the Image folder. After appending select that folder, then choose the .jpg (or any other file format) you want.

Add a new background image in a Properties Shelf (click on Add Image in Background Images panel), then click on an 'image icon' and your appended image'll be available.

• Yes, but this is pain when you have lots of background images which need to be added to lots of files. Just appending the images isn't enough, I'd like a way to make them background images automatically too.
– gandalf3
Oct 8 '15 at 0:48

Maybe you could try importing your images in the first .blend easily with the addon "import images as planes". Then save that .blend

From another .blend, you could be able to link the imported images from the first.

Though I'm not sure this fills your needs, it could work, hopefully.

• The goal is to get the background image entries, just having the images doesn't help all that much
– gandalf3
Oct 8 '15 at 10:07