Files
workinf_Blender_Wasm/tools/web/generate-asset-preview-identity.py
mes123456 5a11045ca5
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
Advance Blender 5.2 web parity through M12-03D
2026-08-17 17:30:27 -04:00

34 lines
1.3 KiB
Python

import pathlib
import sys
import bpy
def main() -> None:
if "--" not in sys.argv or len(sys.argv[sys.argv.index("--") + 1 :]) != 2:
raise SystemExit("usage: blender --background --factory-startup --python generate-asset-preview-identity.py -- INPUT OUTPUT")
source_arg, output_arg = sys.argv[sys.argv.index("--") + 1 :]
source = pathlib.Path(source_arg).resolve()
output = pathlib.Path(output_arg).resolve()
output.parent.mkdir(parents=True, exist_ok=True)
image = bpy.data.images.load(str(source), check_existing=False)
width, height = image.size[:]
scene = bpy.context.scene
scene.render.image_settings.file_format = "PNG"
scene.render.image_settings.color_mode = "RGBA"
scene.render.image_settings.color_depth = "8"
scene.render.image_settings.compression = 0
scene.display_settings.display_device = "sRGB"
scene.view_settings.view_transform = "Standard"
scene.view_settings.look = "None"
scene.view_settings.exposure = 0
scene.view_settings.gamma = 1
image.save_render(str(output), scene=scene)
if not output.is_file() or output.stat().st_size == 0:
raise RuntimeError("asset preview output was not written")
print(f"asset-preview-generated width={width} height={height} output={output}")
main()