gldf-rs-python
Python bindings for the gldf-rs GLDF parsing library.
Overview
gldf-rs-python provides Python access to GLDF (General Lighting Data Format) file parsing and manipulation. It wraps the high-performance Rust gldf-rs library using PyO3/maturin.
GLDF files are ZIP containers containing product.xml definitions along with embedded images, photometry files (Eulumdat/IES), and L3D 3D models.
Learn more at: https://gldf.io
Installation
GLDF Viewer
Quick Start
# Load GLDF and convert to XML
=
# Load GLDF and convert to JSON
=
# Round-trip: JSON back to XML
=
assert == # True
Converting LDT/IES to GLDF
# Convert LDT to GLDF JSON
=
# Convert LDT to GLDF file
=
# Works with IES files too
=
Working with GLDF Bytes
# Load GLDF from bytes (useful for web apps, streaming)
=
# Export GLDF JSON back to bytes
=
API Reference
| Function | Description |
|---|---|
gldf_to_xml(path) |
Load GLDF file and convert to XML string |
gldf_to_json(path) |
Load GLDF file and convert to JSON string |
json_from_xml_str(xml_str) |
Parse XML string to JSON |
xml_from_json(json_str) |
Parse JSON string to XML |
gldf_from_bytes(data) |
Load GLDF from bytes and return JSON |
ldt_to_gldf_json(data, filename) |
Convert LDT/IES to GLDF JSON |
ldt_to_gldf_bytes(data, filename) |
Convert LDT/IES to GLDF bytes (ZIP) |
gldf_json_to_bytes(json_str) |
Export GLDF JSON to bytes (ZIP) |
Development
# Create virtual environment
# Install maturin
# Build and install in development mode
# Build release wheel
Live Demo
Try the WASM-based GLDF viewer at: https://gldf.icu
Related Crates
| Crate | Description |
|---|---|
| gldf-rs | Core Rust library |
| gldf-rs-wasm | WebAssembly viewer application |
| l3d-rs | L3D 3D model format parsing |
| eulumdat | Eulumdat/LDT photometry parsing |
Release Notes
0.3.3
- New:
ldt_to_gldf_json()- Convert LDT/IES photometry to GLDF JSON - New:
ldt_to_gldf_bytes()- Convert LDT/IES photometry to GLDF bytes (ZIP) - New:
gldf_from_bytes()- Load GLDF from bytes and return JSON - New:
gldf_json_to_bytes()- Export GLDF JSON to bytes (ZIP) - Improved error handling with proper
PyValueErrorexceptions - Added
eulumdatfeature for LDT/IES conversion support
0.3.1
- Updated to gldf-rs 0.3.1 with quick-xml parser
- Part of gldf-rs monorepo restructure
0.2.0
- Support for URL file types
- Support for BOM-encoded UTF8 product.xml
License
MIT License