2025-12-01

This commit is contained in:
2026-03-17 14:58:51 -06:00
parent 183e865f8b
commit 4b82b57113
6846 changed files with 954887 additions and 162606 deletions
@@ -18,10 +18,26 @@
import os
import time
from functools import lru_cache
import logging
from dataclasses import dataclass
import bpy
bk_logger = logging.getLogger(__name__)
@dataclass
class IMG:
name: str
filepath: str
def gl_load(self):
"""Imitates bpy.types.Image.gl_load() behavior."""
return None
def get_orig_render_settings():
rs = bpy.context.scene.render
ims = rs.image_settings
@@ -91,21 +107,68 @@ def set_colorspace(img, colorspace: str = ""):
if colorspace == "":
colorspace = guess_colorspace()
if colorspace == "Non-Color":
img.colorspace_settings.is_data = True
else:
img.colorspace_settings.name = colorspace
except Exception as e:
print(f"Colorspace {colorspace} not found: {e}")
if hasattr(img, "colorspace_settings") and colorspace:
if colorspace == "Non-Color":
img.colorspace_settings.is_data = True
else:
img.colorspace_settings.name = colorspace
except Exception:
bk_logger.exception("Colorspace '%s' not found: ", colorspace)
def guess_colorspace():
@lru_cache(maxsize=1)
def list_available_image_colorspaces():
"""Lists available color spaces in blender by creating a temporary image if needed.
Returns:
List of color space names.
"""
# Check if there are existing images
temp_image = None
if bpy.data.images:
img = bpy.data.images[0]
else:
# Create temporary image
temp_image = bpy.data.images.new(
"TempImage_ForColorSpaceList", width=1, height=1
)
img = temp_image
# Get available color spaces
color_spaces = [
cs.identifier
for cs in img.colorspace_settings.bl_rna.properties["name"].enum_items
]
# Clean up temporary image if created
if temp_image:
bpy.data.images.remove(temp_image)
return color_spaces
def guess_colorspace() -> str:
"""Tries to guess the colorspace from the current display device and available color spaces."""
display_device = bpy.context.scene.display_settings.display_device
if display_device == "sRGB":
return "sRGB"
if display_device == "ACES":
return "aces"
# detect available color spaces on image data
all_clr_spaces = list_available_image_colorspaces()
# try to match display device with color space
for cs in all_clr_spaces:
if display_device.lower() in cs.lower():
return cs
# fallback
if "sRGB" in all_clr_spaces:
return "sRGB"
return ""
def analyze_image_is_true_hdr(image):
import numpy