I tried to save a baked image using

bpy.data.images["Image Id Name"].save_render("C:/path/to/file.png")

but this always changes the colorspace and I couldn't find where to set the colorspace for save render in the

Finally I solved it by passing the image editor UI area, where the image is in and using bpy.ops.image.save_as

for window in bpy.context.window_manager.windows:
    screen = window.screen
    for area in screen.areas:
        if area.type == 'IMAGE_EDITOR':
            override = {'window': window, 'screen': screen, 'area': area}
            bpy.data.images['bakedTexture'].filepath_raw = filenameVariations
            bpy.ops.image.save_as(override, filepath = filenameVariations)
            print ("Generated file: ", filenameVariations)

For the future, does anyone know how to do it with save_render?

Because the way I did it, I do not have control over compression and image bit depth.

I am on Blender 2.80

  • 1
    $\begingroup$ You would have to set the color management settings and file format settings in the scene (e.g. bpy.context.scene.view_settings.view_transform, bpy.context.scene.render.image_settings.file_format, bpy.context.scene.render.image_settings.file_format.color_depth, bpy.context.scene.render.image_settings.file_format.compression). I can post this as an answer if it solves your problem. $\endgroup$ – Robert Gützkow Feb 20 at 15:13
  • $\begingroup$ Hey @Robert , thanks for the answer! I had already tried these: # set ImageFormatSettings (only applying to save as render) settings = scene.render.image_settings settings.file_format = "TIFF" settings.color_mode = "RGB" settings.color_depth = "16" settings.quality = 100 settings.tiff_codec = "LZW" but these could not repair the color distortion which is my problem. And in these settings there is no colorspace parameter that could solve the color problem, if I saw right in the API. Any other ideas? THX $\endgroup$ – MarkusKla Feb 24 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.