How to Generate Background Color of Baked Texture from Island Margins? I have a high poly model and I want to bake its diffuse texture to a low poly model.
So here is what I have:

Download the Blender file here:

The result of baking from selected to active looks like this:

However my goal is to replace the transparent background with meaningful color data. Specifically I want the color of the margins to expand into the transparent areas.
Let me show you...
the desired result should look something like this:

I don't want to do it manually.
The goal is to do it automatically with the help of the Blender Python API.
Currently I use something similar to the following code to bake with the Python API:
bake_image = bpy.data.images.new('bake_image',width=2048, height=2048)
bake_node.image = bake_image
bpy.ops.object.bake(type='DIFFUSE')
self.bake_image.filepath_raw = 'bake_image.tif'
self.bake_image.save()
You can set a bigger margin without perturbing the bake itself:

So the result is:

And the models are still quite nice:

So for the api, use the margin parameter:
bpy.ops.object.bake(type='DIFFUSE', margin=512)