html2pix 0.6.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ [workspace]
2
+ resolver = "2"
3
+ members = ["crates/html2pix-core", "crates/html2pix-python"]
4
+
5
+ [workspace.package]
6
+ version = "0.6.3"
7
+ edition = "2021"
8
+ authors = ["Mel Massadian"]
9
+ license = "MIT"
10
+ repository = "https://github.com/melmass/comfyui_html_render"
11
+
12
+ [workspace.metadata.release]
13
+ # crates.io publish is disabled per-crate via `publish = false` in each
14
+ # [package] (cargo-release honors the standard Cargo field; the workspace
15
+ # metadata key is not inherited). Distribution is PyPI wheels + binaries.
16
+ push = false # review locally, then `git push --follow-tags`
17
+ shared-version = true # all crates + pyproject move together
18
+ consolidate-commits = true # one bump commit for the whole workspace
19
+ tag-name = "v{{version}}"
20
+ pre-release-commit-message = "chore(release): v{{version}}"
21
+
22
+ [workspace.dependencies]
23
+ # Core rendering dependencies
24
+ anyrender = "0.10"
25
+ anyrender_vello_cpu = { version = "0.13", features = ["multithreading"] }
26
+ image = "0.25"
27
+ anyhow = "1.0"
28
+ thiserror = "2.0"
29
+ wide = "1.4"
30
+
31
+ # Blitz HTML rendering (from git)
32
+ blitz-dom = { git = "https://github.com/DioxusLabs/blitz", rev = "191a6cfd75363911121ed57ff24a9f5af131fdc0" }
33
+ blitz-html = { git = "https://github.com/DioxusLabs/blitz", rev = "191a6cfd75363911121ed57ff24a9f5af131fdc0" }
34
+ blitz-paint = { git = "https://github.com/DioxusLabs/blitz", rev = "191a6cfd75363911121ed57ff24a9f5af131fdc0" }
35
+ blitz-traits = { git = "https://github.com/DioxusLabs/blitz", rev = "191a6cfd75363911121ed57ff24a9f5af131fdc0" }
36
+
37
+ # Python bindings (optional)
38
+ pyo3 = { version = "0.28", features = [
39
+ "extension-module",
40
+ "generate-import-lib",
41
+ ] }
42
+ numpy = "0.28"
43
+ ndarray = "0.17"
44
+
45
+ # CLI dependencies
46
+ clap = { version = "4.6", features = ["derive"] }
47
+
48
+ # Swift/multi-language bindings
49
+ uniffi = "0.31"
50
+
51
+ [profile.release]
52
+ lto = "thin"
53
+ codegen-units = 1
54
+ strip = true
55
+ panic = "abort"
56
+ opt-level = 3
html2pix-0.6.3/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Mel Massadian
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,399 @@
1
+ Metadata-Version: 2.4
2
+ Name: html2pix
3
+ Version: 0.6.3
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Classifier: Programming Language :: Rust
13
+ Classifier: Programming Language :: Python :: Implementation :: CPython
14
+ Classifier: Topic :: Multimedia :: Graphics
15
+ Classifier: Topic :: Multimedia :: Video
16
+ Requires-Dist: numpy>=1.24.4
17
+ Requires-Dist: pillow>=10.4.0
18
+ License-File: LICENSE
19
+ License-File: THIRD-PARTY-LICENSES.html
20
+ Summary: Fast HTML to pixel rendering using Rust and Blitz. Generate production slates, overlays, and presentations.
21
+ Keywords: html,rendering,image,video,slate,presentation,rust,blitz
22
+ Author-email: Mel Massadian <7041726+melMass@users.noreply.github.com>
23
+ License-Expression: MIT
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
26
+
27
+ # html2pix
28
+
29
+ [![CI](https://github.com/melMass/html2pix/actions/workflows/ci.yml/badge.svg)](https://github.com/melMass/html2pix/actions/workflows/ci.yml)
30
+ [![PyPI](https://img.shields.io/pypi/v/html2pix)](https://pypi.org/project/html2pix)
31
+ [![version](https://img.shields.io/badge/version-v0.6.3-blue)](https://pypi.org/project/html2pix)
32
+
33
+ Fast HTML to pixel rendering using Rust and [Blitz](https://github.com/DioxusLabs/blitz). Generate production slates, video overlays, and presentation graphics from HTML/CSS templates.
34
+
35
+
36
+ ## ✨ Features
37
+
38
+ - 🎨 **Modern CSS Support**: Gradients, flexbox, grid, border-radius, shadows
39
+ - πŸ“ **Professional Templates**: Presentation templates (title cards, credits, quotes, chapters)
40
+ - 🎬 **Video Slate Generation**: Production-ready metadata overlays for videos
41
+ - πŸ–ΌοΈ **Image Compositing**: Alpha blend HTML over images and video frames
42
+ - 🎯 **RGB/RGBA Output**: Full transparency support
43
+ - πŸ’… **CSS Styling**: Complete CSS customization
44
+ - ⚑ **SIMD-Accelerated**: 4x faster compositing using vector instructions
45
+ - πŸš€ **Native Performance**: Built with Rust/PyO3 for speed
46
+ - πŸ”Œ **ComfyUI Integration**: Optional node for ComfyUI workflows
47
+
48
+ ## πŸš€ Installation
49
+
50
+ ### From PyPI
51
+
52
+ ```bash
53
+ # Standard installation
54
+ pip install html2pix
55
+
56
+ # With ComfyUI support
57
+ pip install html2pix[comfyui]
58
+ ```
59
+
60
+ ### CLI binary
61
+
62
+ Prebuilt binaries for macOS, Linux (glibc + static musl), and Windows are on the
63
+ [downloads page](https://melmass.github.io/html2pix/). Once installed, the CLI
64
+ updates itself in place:
65
+
66
+ ```bash
67
+ html2pix --self-update # install the latest release
68
+ html2pix --self-update --check # only report whether one is available
69
+ ```
70
+
71
+ ### From Source
72
+
73
+ Requires:
74
+ - **Rust toolchain**: Install from [rustup.rs](https://rustup.rs)
75
+ - **Python 3.10+**
76
+
77
+ ```bash
78
+ git clone https://github.com/melMass/html2pix.git
79
+ cd html2pix
80
+
81
+ # Install with uv (recommended - avoids caching issues)
82
+ uv pip install maturin
83
+ uv run maturin develop --uv --release
84
+
85
+ # Or with pip
86
+ pip install maturin
87
+ maturin develop --release
88
+ ```
89
+
90
+ ## πŸ“– Usage
91
+
92
+ ### Python API
93
+
94
+ #### Basic HTML Rendering
95
+
96
+ ```python
97
+ from html2pix_ext import render_html
98
+ from pathlib import Path
99
+ import numpy as np
100
+
101
+ # Render HTML to pixels
102
+ html = "<h1>Hello World</h1>"
103
+ image = render_html(
104
+ html=html,
105
+ css_override=None,
106
+ width=800,
107
+ height=600,
108
+ bg_color=(255, 255, 255, 255),
109
+ input_image=None,
110
+ output_format="RGBA",
111
+ scale_factor=1.0, # DPI scaling (1.0=normal, 2.0=retina)
112
+ color_scheme="light", # "light" or "dark"
113
+ time=0.0, # Animation time in seconds
114
+ resources=None # Optional: custom fonts/images
115
+ )
116
+
117
+ # Result is numpy array (batch, height, width, channels)
118
+ print(image.shape) # (1, 600, 800, 4)
119
+ ```
120
+
121
+ #### Using Custom Fonts
122
+
123
+ ```python
124
+ from pathlib import Path
125
+
126
+ # Load custom font
127
+ font_data = Path('fonts/Inter-Bold.woff2').read_bytes()
128
+
129
+ html = """
130
+ <style>
131
+ @font-face {
132
+ font-family: 'Inter';
133
+ src: url('Inter-Bold.woff2');
134
+ }
135
+ h1 { font-family: 'Inter', sans-serif; }
136
+ </style>
137
+ <h1>Custom Typography!</h1>
138
+ """
139
+
140
+ image = render_html(
141
+ html=html,
142
+ width=800,
143
+ height=600,
144
+ resources={
145
+ 'Inter-Bold.woff2': font_data # Clean API with Path().read_bytes()
146
+ }
147
+ )
148
+ ```
149
+
150
+ #### Using Templates
151
+
152
+ ```python
153
+ from templates import render_template
154
+
155
+ # Render a title card
156
+ html, css = render_template('title_card', {
157
+ 'title': 'Neural Dreams',
158
+ 'subtitle': 'A journey through artificial imagination',
159
+ 'info': 'Production Company',
160
+ 'bottom_text': '2024 β€’ Runtime 4:48'
161
+ })
162
+
163
+ # Render to pixels
164
+ image = render_html(
165
+ html=html,
166
+ css_override=css,
167
+ width=1920,
168
+ height=1080,
169
+ bg_color=(10, 10, 10, 255),
170
+ input_image=None,
171
+ output_format="RGBA"
172
+ )
173
+ ```
174
+
175
+ ### Available Templates
176
+
177
+ **Professional Design System** - All templates follow a minimalist, sophisticated aesthetic:
178
+
179
+ 1. **`title_card`** - Bold, centered title cards for opening sequences
180
+ 2. **`chapter_card`** - Minimal section markers with timestamps
181
+ 3. **`quote_card`** - Elegant text presentation with attribution
182
+ 4. **`credits_card`** - End credits style with role/name pairs
183
+ 5. **`minimal_overlay`** - Subtle corner text (4-position support)
184
+
185
+ ### Video Processing
186
+
187
+ **Simple watermark** (3 lines):
188
+ ```python
189
+ from html2pix.video import apply_html_overlay
190
+
191
+ html = '<div style="position: absolute; top: 20px; left: 20px;">My Watermark</div>'
192
+ apply_html_overlay('input.mp4', 'output.mp4', html)
193
+ ```
194
+
195
+ **Dynamic per-frame overlays**:
196
+ ```python
197
+ from html2pix.video import process_video
198
+
199
+ def add_frame_counter(frame, frame_num, info):
200
+ html = f'<div>Frame: {frame_num}/{info["total_frames"]}</div>'
201
+ frame_batch = frame[np.newaxis, ...]
202
+ result = render_html(html, width=info['width'], height=info['height'], input_image=frame_batch)
203
+ return result[0]
204
+
205
+ process_video('input.mp4', 'output.mp4', add_frame_counter)
206
+ ```
207
+
208
+ **VFX breakdown slates**:
209
+ ```python
210
+ from html2pix import generate_video_slate_html
211
+ from html2pix.video import process_video
212
+
213
+ metadata = {
214
+ 'title': 'VFX Shot Breakdown',
215
+ 'fps': 25,
216
+ 'total_frames': 121,
217
+ 'inference_settings': {'model': 'SDXL', 'steps': 50},
218
+ 'prompt': 'Cinematic establishing shot...'
219
+ }
220
+
221
+ html, css = generate_video_slate_html(metadata, layout='side-by-side')
222
+
223
+ def add_slate(frame, frame_num, info):
224
+ # Your slate compositing logic here
225
+ ...
226
+
227
+ process_video('input.mp4', 'output_with_slate.mp4', add_slate)
228
+ ```
229
+
230
+ See [examples/showcase_video.py](examples/showcase_video.py) for complete examples.
231
+
232
+ ### ComfyUI Integration
233
+
234
+ When installed with `pip install html2pix[comfyui]`:
235
+
236
+ 1. Copy `__init__.py` to `ComfyUI/custom_nodes/html2pix/`
237
+ 2. Restart ComfyUI
238
+ 3. Find node under `mtb/render β†’ HTML Render (Blitz)`
239
+
240
+ ## 🎬 Template Examples
241
+
242
+ All templates render at 1920x1080 with professional typography and spacing:
243
+
244
+ ### Title Card
245
+ ```python
246
+ render_template('title_card', {
247
+ 'title': 'Neural\nDreams',
248
+ 'subtitle': 'A journey through artificial imagination',
249
+ 'info': 'Production Company',
250
+ 'bottom_text': '2024 β€’ Runtime 4:48'
251
+ })
252
+ ```
253
+
254
+ ### Quote Card
255
+ ```python
256
+ render_template('quote_card', {
257
+ 'context': 'On Creation',
258
+ 'quote': 'The machine does not dream, but it learns to paint our dreams.',
259
+ 'attribution': 'β€” Unknown Artist, 2024'
260
+ })
261
+ ```
262
+
263
+ ### Credits Card
264
+ ```python
265
+ render_template('credits_card', {
266
+ 'title': 'Neural Dreams',
267
+ 'credits': [
268
+ {'role': 'Directed by', 'name': 'Mel Massadian'},
269
+ {'role': 'Generated with', 'name': 'Stable Diffusion XL'},
270
+ {'role': 'Rendered by', 'name': 'html2pix'},
271
+ ],
272
+ 'closing': 'Thank you for watching'
273
+ })
274
+ ```
275
+
276
+ ## πŸ—οΈ Architecture
277
+
278
+ ```
279
+ html2pix/
280
+ β”œβ”€β”€ __init__.py # Python API + ComfyUI node (optional)
281
+ β”œβ”€β”€ templates.py # Professional template system
282
+ β”œβ”€β”€ slate_compositor.py # Reference image compositing
283
+ β”œβ”€β”€ frame_scaler.py # Video/image scaling utilities
284
+ β”œβ”€β”€ render_full_video.py # Full video processing
285
+ β”œβ”€β”€ extension/ # Rust rendering engine
286
+ β”‚ β”œβ”€β”€ Cargo.toml # Dependencies (Blitz, wide for SIMD)
287
+ β”‚ └── src/lib.rs # SIMD-optimized compositor
288
+ └── pyproject.toml # Package configuration
289
+ ```
290
+
291
+ ### How It Works
292
+
293
+ 1. **HTML/CSS Parsing** β†’ Blitz HtmlDocument with style resolution
294
+ 2. **Layout Engine** β†’ Compute flexbox, grid, and positioning
295
+ 3. **Rendering** β†’ Blitz paints to RGBA buffer via CPU renderer
296
+ 4. **SIMD Compositing** β†’ Alpha blend using vectorized operations (4 pixels/instruction)
297
+ 5. **Batch Processing** β†’ Composite HTML over video frames or images
298
+ 6. **Output** β†’ Return as numpy arrays (batch, height, width, channels)
299
+
300
+ #### SIMD Acceleration
301
+
302
+ The compositor uses **SIMD (Single Instruction, Multiple Data)** for 4x faster alpha blending:
303
+
304
+ ```rust
305
+ // Traditional: Process 1 pixel at a time
306
+ for pixel in pixels {
307
+ out = html * alpha + bg * (1 - alpha) // 1 pixel per cycle
308
+ }
309
+
310
+ // SIMD: Process 4 pixels with ONE instruction
311
+ let pixels_vec = f32x4::new([p1, p2, p3, p4]);
312
+ let out = html * alphas + bg * one_minus_alpha; // 4 pixels per cycle!
313
+ ```
314
+
315
+ **Performance:**
316
+ - 1920Γ—1080 render: **~65ms** (down from ~100-150ms)
317
+ - Uses `f32x4` vectors via the `wide` crate
318
+ - Maps to native CPU instructions (SSE/AVX on x86, NEON on ARM)
319
+
320
+ ## πŸ”§ Technical Details
321
+
322
+ ### Dependencies
323
+
324
+ **Core:**
325
+ - numpy >=1.24.4
326
+ - pillow >=10.4.0
327
+
328
+ **Optional (ComfyUI):**
329
+ - torch >=2.0.0
330
+
331
+ **Rust (Bundled in wheels):**
332
+ - Blitz (commit `2044d690`) - HTML/CSS rendering
333
+ - PyO3 (0.22) - Python bindings
334
+ - anyrender_vello_cpu (0.7) - CPU renderer with multithreading
335
+ - wide (0.7) - Portable SIMD intrinsics
336
+
337
+ ### Performance
338
+
339
+ - **Rendering**: SIMD-accelerated, ~65ms for 1920x1080
340
+ - **Compositing**: 4x faster with f32x4 vector operations
341
+ - **Video Processing**: Efficient frame-by-frame with progress
342
+ - **Build Time**: ~6-8 seconds (incremental), ~2 minutes (clean)
343
+ - **Tested**: Up to 1920x1080 @ 25fps, 121-frame videos
344
+
345
+ ### Supported CSS Features
346
+
347
+ βœ… Flexbox & Grid layouts
348
+ βœ… Gradients (linear, radial)
349
+ βœ… Border radius & box shadows
350
+ βœ… Typography (font-size, weight, color, line-height)
351
+ βœ… Padding, margin, spacing
352
+ βœ… Colors (hex, rgb, rgba)
353
+ βœ… Text anti-aliasing & smooth rendering
354
+
355
+ ## 🚧 Limitations
356
+
357
+ - Custom resources must be pre-loaded (no live HTTP/filesystem loading)
358
+ - CPU rendering only (no GPU acceleration yet)
359
+ - No JavaScript support (static HTML/CSS only)
360
+ - Blitz is pre-alpha (some advanced CSS features may be incomplete)
361
+
362
+ ## πŸ—ΊοΈ Roadmap
363
+
364
+ - [x] Multi-platform wheel builds (Linux, macOS, Windows)
365
+ - [x] Professional template system
366
+ - [x] Video slate generation
367
+ - [x] SIMD-accelerated compositing
368
+ - [x] Custom font/image loading (pre-bundle API)
369
+ - [ ] Publish to PyPI
370
+ - [ ] GPU renderer option
371
+ - [ ] Auto-loading resources from filesystem/HTTP
372
+ - [ ] More template styles
373
+ - [ ] CSS animation support (time parameter ready)
374
+
375
+ ## πŸ“š Documentation
376
+
377
+ - **[BLITZ_API.md](BLITZ_API.md)**: Blitz rendering API
378
+ - **[CLAUDE.md](CLAUDE.md)**: Development log and technical decisions
379
+
380
+ ## 🀝 Contributing
381
+
382
+ Contributions welcome! The package is structured to make ComfyUI integration optional while providing a powerful standalone Python library.
383
+
384
+ ## πŸ“„ License
385
+
386
+ MIT License - See LICENSE file
387
+
388
+ ## πŸ™ Credits
389
+
390
+ - **[Blitz](https://github.com/DioxusLabs/blitz)** by DioxusLabs - Blazing fast HTML/CSS rendering engine
391
+ - **[wide](https://github.com/Lokathor/wide)** by Lokathor - Portable SIMD intrinsics for Rust
392
+ - Built with Rust, PyO3, and love for beautiful design
393
+
394
+ ## πŸ”— Links
395
+
396
+ - **PyPI**: https://pypi.org/project/html2pix/
397
+ - **GitHub**: https://github.com/melMass/html2pix
398
+ - **Issues**: https://github.com/melMass/html2pix/issues
399
+