Pure image rendering from drawing instructions for e-paper displays
Project description
odl-renderer
Python renderer for the OpenDisplay Language (ODL).
odl-renderer is a standalone Python library for generating images from ODL drawing instructions. Originally extracted from the OpenEPaperLink Home Assistant integration, it provides a clean, async API for rendering text, shapes, icons, QR codes, and more to PIL images.
Features
- Pure Rendering: No dependencies on Home Assistant or other frameworks
- 17 Element Types: Text, shapes, icons, QR codes, images, progress bars, and more
- Async/Await: Modern async API for efficient image generation
- Flexible Input: Accepts fonts as PIL objects, file paths, or built-in names
- Full Color Output: Returns PIL Image objects in full RGB/RGBA (caller handles dithering)
- Percentage-Based Coordinates: Position elements using percentages or absolute pixels
- Template-Ready: All values are plain data (templates expanded by caller)
Installation
uv add odl-renderer
# or
pip install odl-renderer
Quickstart
from odl_renderer import generate_image
# Generate a simple image
image = await generate_image(
width=296,
height=128,
elements=[
{
"type": "text",
"value": "Hello World",
"x": "50%",
"y": 50,
"font": "ppb",
"size": 24,
"color": "black",
"anchor": "mm"
},
{
"type": "rectangle",
"x_start": 10,
"y_start": 10,
"x_end": 100,
"y_end": 50,
"fill": "red",
"outline": "black",
"width": 2
},
],
background="white",
accent_color="red"
)
# Save the image
image.save("output.png")
Element Types
Text Elements
Text
Single line or multi-line text with wrapping support.
{
"type": "text",
"value": "Hello World",
"x": "50%",
"y": 50,
"font": "ppb", # Built-in font name, path, or PIL Font object
"size": 24,
"color": "black",
"anchor": "mm", # Anchor point (e.g., mm = middle-middle)
"max_width": 200, # Optional text wrapping
"truncate": False, # Truncate with ellipsis instead of wrapping
"align": "center", # left, center, right
}
multiline
Multi-line text with delimiter-based line breaks.
{
"type": "multiline",
"value": "Line 1|Line 2|Line 3",
"delimiter": "|",
"x": 10,
"y": 10,
"offset_y": 20, # Pixels between lines
"font": "ppb",
"size": 16,
}
etc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odl_renderer-0.5.0.tar.gz.
File metadata
- Download URL: odl_renderer-0.5.0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2de75c028fd461dd04af1b0af145d5a8b97e40b7ec044e9fe2a090aca5f87411
|
|
| MD5 |
20c53d196c6053fc7e5eb4a12b0cae2d
|
|
| BLAKE2b-256 |
c027cafe7fd95583e1cada45e957af70233f54cce18b03ff17ab83bb48ca12d4
|
File details
Details for the file odl_renderer-0.5.0-py3-none-any.whl.
File metadata
- Download URL: odl_renderer-0.5.0-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f935fad0cd72c16a7cefe697a7ee14995e7973ac5bac8a4d5be0edb6c71abe44
|
|
| MD5 |
af76e263b4bde2ed9121ba17f927a434
|
|
| BLAKE2b-256 |
096d212b057e63f21e0efeffe6e6181733367b9849adc9ba3dc8dcfb0c6980d0
|