Export UVs to .png - output with alpha is different when launched from command line I need to programmatically export the UVs of a lot of .objs. I am using the bpy.ops.uv.export_layout() fn. 

Since  this step is part of a more complex pipeline, I am launching Python from the command line passing the script as a -P parameter. 

I run into a pretty important issue: if I launch Blender manually and run the script, or from a terminal as explained above, I obtain two different images. I am using the same parameters while exporting.

I run some tests on Suzanne. Here are the images: 





The difference is especially clear if you check their alpha channels:





You will see that in the command line one the wire is visible in the alpha, and this breaks the rest of the workflow that I need to perform on the image.

Any idea on what's going on?
Thank you!

Ps: here's a minimal example script to replicate the issue.

Set the export path.
On Macos, launch with "blender_path -P script_path".
Comment last line when launching from Blender!

import bpy

output_path = "YOUR_EXPORT_PATH_HERE"

if __name__ == "__main__":

    for o in bpy.data.objects:
        bpy.data.objects.remove(o, do_unlink=True)

    bpy.ops.mesh.primitive_monkey_add(enter_editmode=True, location=(0, 0, 0))

    bpy.ops.uv.export_layout(filepath=str(output_path), export_all=False, modified=False, mode='PNG',
                             size=(1024, 1024), opacity=1)

    print ("Done")

    bpy.ops.wm.quit_blender()
I did exactly the same thing you did, exported the UVs from the Suzanne.

Though i did export it twice with once default opacity 0.25 and once with it set to 1 as you use in the script.

The code is taken from the Scripting Tab bottom left window. Here we can see as in the picture below, the default 0.25 function framed red(default value is optional and does not show up in the function used), the value of 1 (is not default, so the value shows up as parameter) in green:



bpy.ops.uv.export_layout(filepath="..\\Suzanne.png", size=(1024, 1024))


When compared to the one you use, there is a significant difference. Opacity by default when using the menu is 0.25, while in your script you use "opacity=1".



Using:

bpy.ops.uv.export_layout(filepath="..\\Suzanne1.png", size=(1024, 1024), opacity=0.25)


i got the exact same image as i got from when i used the menu function without changing the opacity.

So i would suggest you try your script with the adjustment of the opacity to "0.25".
That should do the trick.