diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2021-02-10 22:18:06 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2021-02-10 22:18:06 +0300 |
commit | e5a2d98c827b54052688c90113a12e5c661149c3 (patch) | |
tree | 9601ddb6bc451a1a96517a413be781e64ee650cc /blenderkit/image_utils.py | |
parent | 4791208720cee54a76e92431a92bc81937d1f46a (diff) | |
parent | 3ce41afdfa56a9eef6934dc012e5621a74ebbb7b (diff) |
Merge branch 'blender-v2.92-release'
Diffstat (limited to 'blenderkit/image_utils.py')
-rw-r--r-- | blenderkit/image_utils.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/blenderkit/image_utils.py b/blenderkit/image_utils.py index 96bad204..fce1cafd 100644 --- a/blenderkit/image_utils.py +++ b/blenderkit/image_utils.py @@ -54,6 +54,17 @@ def img_save_as(img, filepath='//', file_format='JPEG', quality=90, color_mode=' set_orig_render_settings(ors) +def set_colorspace(img, colorspace): + '''sets image colorspace, but does so in a try statement, because some people might actually replace the default + colorspace settings, and it literally can't be guessed what these people use, even if it will mostly be the filmic addon. + ''' + try: + if colorspace == 'Non-Color': + img.colorspace_settings.is_data = True + else: + img.colorspace_settings.name = colorspace + except: + print(f'Colorspace {colorspace} not found.') def generate_hdr_thumbnail(): scene = bpy.context.scene @@ -79,7 +90,7 @@ def generate_hdr_thumbnail(): hdr_image.pixels.foreach_get(tempBuffer) inew.filepath = thumb_path - inew.colorspace_settings.name = 'Linear' + set_colorspace(inew, 'Linear') inew.pixels.foreach_set(tempBuffer) bpy.context.view_layer.update() |