https://github.com/avvertix/html-shot
HTML to image rendering for PHP, powered by Rust and Takumi. Generate Open Graph images and more from HTML/CSS without requiring a headless browser.
https://github.com/avvertix/html-shot
html-to-image open-graph php
Last synced: 3 months ago
JSON representation
HTML to image rendering for PHP, powered by Rust and Takumi. Generate Open Graph images and more from HTML/CSS without requiring a headless browser.
- Host: GitHub
- URL: https://github.com/avvertix/html-shot
- Owner: avvertix
- License: mit
- Created: 2026-04-21T09:04:10.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-22T06:52:15.000Z (3 months ago)
- Last Synced: 2026-04-22T08:10:21.778Z (3 months ago)
- Topics: html-to-image, open-graph, php
- Language: PHP
- Homepage:
- Size: 304 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# html-shot
HTML to image rendering for PHP, powered by Rust and [Takumi](https://github.com/kane50613/takumi).
Generate Open Graph images and more from HTML/CSS without headless browser overhead.
## Features
_tbd_
### HTML & CSS Support
| Input | Behaviour |
|-------|-----------|
| `` tags | CSS extracted and applied as a stylesheet |
| Inline `style="..."` | Promoted to a generated CSS class rule |
| `<img src="...">` | Local paths and data URIs supported |
| CSS `background-image: url(...)` | Local paths and data URIs supported |
| `<br>` | Rendered as a newline |
| `<html>`, `<head>`, `<body>` | Transparent wrappers, stripped |
| All other elements | Rendered as Takumi container nodes (`class`, `id`, `tagName` forwarded) |
Takumi's layout engine supports **Flexbox**, **CSS Grid**, `tw` Tailwind utility classes, and CSS
animations.
## Installation
```bash
composer require avvertix/html-shot
```
**Requirements**
- PHP 8.2 or higher
- FFI extension enabled `ext-ffi` | enabled (`ffi.enable = true` in `php.ini`) |
## Quick Example
_tbd_
## Development
```bash
git clone https://github.com/avvertix/html-shot.git
cd html-shot
# Install PHP dependencies
composer install
# Build the Rust library
cd rust && cargo build --release
```
### Build the native library
The Rust library must be compiled for your target platform. A pre-built binary is attached to each GitHub release or you can build your own.
```bash
cd vendor/avvertix/html-shot/rust
cargo build --release
```
Then copy the compiled library to the `lib/` directory at the package root:
| Platform | Source | Destination |
|----------|--------|-------------|
| Linux | `target/release/libhtml_shot.so` | `../lib/libhtml_shot.so` |
| macOS | `target/release/libhtml_shot.dylib` | `../lib/libhtml_shot.dylib` |
| Windows | `target/release/html_shot.dll` | `../lib/html_shot.dll` |
The C header is auto-generated by cbindgen and written to `include/html_shot.h` during the build.
## Troubleshooting
### Enabling ext-ffi
Check whether FFI is active:
```bash
php -m | grep FFI
```
If it is not listed, add the following to your `php.ini` and restart PHP-FPM / your web server:
```ini
extension=ffi
ffi.enable=true
```
## Contributing
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## License
MIT License - see [LICENSE](LICENSE.md) file for details.
## Credits
Powered by [Takumi](https://github.com/kane50613/takumi)