Skip to content

Commit f8d8d44

Browse files
committed
add PHP and python docs
1 parent f52f7da commit f8d8d44

8 files changed

Lines changed: 155 additions & 5 deletions

File tree

‎changelog.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ Always improving. Updates to HTML/CSS to Image are posted here.
1616

1717
If you have feature requests, please send them to us: support@htmlcsstoimage.com.
1818

19+
### Official Python and PHP clients
20+
September 3, 2026
21+
{: .text-delta}
22+
23+
Official HTML/CSS to Image clients are now available for Python and PHP. Each package provides typed requests and responses, configurable HTTP transport, and helpers for templates, batches, render options, image deletion, and signed URLs.
24+
25+
- Python: [`html-css-to-image` on PyPI](https://pypi.org/project/html-css-to-image/) and the [Python examples](/example-code/python/).
26+
- PHP: [`html-css-to-image/client` on Packagist](https://packagist.org/packages/html-css-to-image/client) and the [PHP examples](/example-code/php/).
27+
28+
The complete package documentation is maintained in the [Python](https://github.com/htmlcsstoimage/python-client) and [PHP](https://github.com/htmlcsstoimage/php-client) repositories.
29+
30+
<hr>
31+
1932
### HTML/CSS to Image is now verified by n8n
2033
September 2, 2026
2134
{: .text-delta}

‎example-code/index.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ We provide example code for popular languages, but the API works the same way ev
3838

3939
## Start with a client library
4040

41-
If you are using TypeScript, JavaScript, or .NET, start with the official clients. They include helpers for authentication, JSON requests, templates, and signed image URLs.
41+
If you are using TypeScript, JavaScript, .NET, Python, or PHP, start with the official clients. They include helpers for authentication, JSON requests, templates, and signed image URLs.
4242

4343
| Language | Recommended starting point |
4444
|:---------|:---------------------------|
4545
| TypeScript / JavaScript | [Official npm client](/example-code/typescript/#official-npm-client) |
4646
| C# / .NET | [Official NuGet package](/example-code/c/) |
47+
| Python | [Official PyPI client](/example-code/python/#official-pypi-client) |
48+
| PHP | [Official Composer client](/example-code/php/#official-composer-client) |
4749

48-
The other examples stay close to each language's standard HTTP and JSON tools, adding a popular client library only when the language does not include one.
50+
The pages also include direct HTTP examples when you want to work with the API without an SDK.
4951

5052
---
5153

‎example-code/php.md‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,51 @@ parent: Example code
66
permalink: /example-code/php/
77
description: >-
88
Convert HTML to an image (png, jpg or webp) with PHP + the HTML/CSS to Image
9-
API. Renders exactly like Google Chrome.
9+
API. Official Composer package for PHP 8.2+.
1010
---
1111
{% include intro.md language="PHP" %}
1212

13+
## Official Composer client
14+
15+
For typed requests, responses, and signed URL helpers, use the official [`html-css-to-image/client`](https://packagist.org/packages/html-css-to-image/client) package.
16+
17+
```bash
18+
composer require html-css-to-image/client
19+
```
20+
21+
```php
22+
<?php
23+
24+
use HtmlCssToImage\HtmlCssToImageClient;
25+
use HtmlCssToImage\Request\CreateHtmlCssImageRequest;
26+
use HtmlCssToImage\Response\CreateImageSuccessResponse;
27+
28+
require __DIR__ . '/vendor/autoload.php';
29+
30+
$client = new HtmlCssToImageClient(
31+
apiId: 'your-api-id',
32+
apiKey: 'your-api-key',
33+
);
34+
35+
$result = $client->createImage(
36+
new CreateHtmlCssImageRequest(
37+
html: "<div class='box'>PHP ✅</div>",
38+
css: '.box { border: 4px solid #03B875; padding: 20px; }',
39+
),
40+
);
41+
42+
if ($result instanceof CreateImageSuccessResponse) {
43+
echo $result->url;
44+
} else {
45+
echo $result->error;
46+
}
47+
```
48+
49+
The client also supports URL screenshots, templates, batches, image deletion, render options, and signed URLs. See the [PHP client repository](https://github.com/htmlcsstoimage/php-client) for complete usage and API documentation.
50+
51+
<hr>
52+
53+
## Direct HTTP example
1354

1455
```php
1556
{% include_snippet everything from snippets/plain_php.php %}

‎example-code/python.md‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,41 @@ parent: Example code
66
permalink: /example-code/python/
77
description: >-
88
Convert HTML to an image (png, jpg or webp) with Python + the HTML/CSS to Image
9-
API. Renders images exactly like Google Chrome.
9+
API. Official PyPI package for Python 3.10+.
1010
---
1111
{% include intro.md language="Python" %}
1212

13+
## Official PyPI client
14+
15+
For typed requests, responses, and signed URL helpers, use the official [`html-css-to-image`](https://pypi.org/project/html-css-to-image/) package.
16+
17+
```bash
18+
pip install html-css-to-image
19+
```
20+
21+
```python
22+
from html_css_to_image import CreateHtmlCssImageRequest, HtmlCssToImageClient
23+
24+
with HtmlCssToImageClient("your-api-id", "your-api-key") as client:
25+
result = client.create_image(
26+
CreateHtmlCssImageRequest(
27+
html="<div class='box'>Python ✅</div>",
28+
css=".box { border: 4px solid #03B875; padding: 20px; }",
29+
)
30+
)
31+
32+
if result.success:
33+
print(result.url)
34+
else:
35+
print(result.status_code, result.error)
36+
```
37+
38+
The client also supports URL screenshots, templates, batches, image deletion, render options, and signed URLs. See the [Python client repository](https://github.com/htmlcsstoimage/python-client) for complete usage and API documentation.
39+
40+
<hr>
41+
42+
## Direct HTTP example
43+
1344
```python
1445
# pip3 install requests
1546
import requests

‎getting-started/create-and-render.md‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ author=%7B%22name%22%3A%22Jeff%22%7D&title=%22Launch%22
119119

120120
The `author` value decodes to `{"name":"Jeff"}`. The `title` value decodes to `"Launch"`.
121121

122-
{% include hint.md title="Use an official client" text="The [TypeScript](/example-code/typescript/) and [.NET](/example-code/c/) clients include signed URL helpers (`generateTemplatedImageUrl` and `CreateTemplatedImageUrl`) so you do not need to hand-build the query string or HMAC token." %}
122+
{% include hint.md title="Use an official client" text="The [TypeScript](/example-code/typescript/), [.NET](/example-code/c/), [Python](/example-code/python/), and [PHP](/example-code/php/) clients include signed URL helpers so you do not need to hand-build the query string or HMAC token." %}
123123

124124
<hr>
125125

@@ -197,6 +197,37 @@ var imageUrl = client.CreateTemplatedImageUrl(
197197
});
198198
```
199199

200+
#### [Python Client](/example-code/python/#official-pypi-client)
201+
202+
```python
203+
from html_css_to_image import HtmlCssToImageClient
204+
205+
with HtmlCssToImageClient.from_env() as client:
206+
image_url = client.generate_templated_image_url_from_values(
207+
"t-b0354248-e7f6-4cca-81c6-2b4a70a16388",
208+
{
209+
"title": "Launch",
210+
"author": {"name": "Avery"},
211+
},
212+
)
213+
```
214+
215+
#### [PHP Client](/example-code/php/#official-composer-client)
216+
217+
```php
218+
use HtmlCssToImage\HtmlCssToImageClient;
219+
220+
$client = HtmlCssToImageClient::fromEnvironment();
221+
222+
$imageUrl = $client->generateTemplatedImageUrlFromValues(
223+
't-b0354248-e7f6-4cca-81c6-2b4a70a16388',
224+
[
225+
'title' => 'Launch',
226+
'author' => ['name' => 'Avery'],
227+
],
228+
);
229+
```
230+
200231

201232

202233
### JavaScript example

‎llms-full.txt‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,30 @@ Use the official npm package for typed requests and helper methods in Node.js/Ty
379379

380380
---
381381

382+
## Official Python Client (PyPI)
383+
384+
Use the official Python package for typed requests and responses, configurable HTTPX transport, and signed URL helpers.
385+
386+
- **Package:** `html-css-to-image`
387+
- **Install:** `pip install html-css-to-image`
388+
- **Docs:** https://docs.htmlcsstoimage.com/example-code/python/
389+
- **PyPI:** https://pypi.org/project/html-css-to-image/
390+
- **GitHub:** https://github.com/htmlcsstoimage/python-client
391+
392+
---
393+
394+
## Official PHP Client (Packagist)
395+
396+
Use the official Composer package for typed requests and responses, injectable PSR-18 transport, and signed URL helpers.
397+
398+
- **Package:** `html-css-to-image/client`
399+
- **Install:** `composer require html-css-to-image/client`
400+
- **Docs:** https://docs.htmlcsstoimage.com/example-code/php/
401+
- **Packagist:** https://packagist.org/packages/html-css-to-image/client
402+
- **GitHub:** https://github.com/htmlcsstoimage/php-client
403+
404+
---
405+
382406
## Code Examples
383407

384408
### Python

‎llms.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ Use OG Image Configs for social cards tied to existing public pages. Use the sta
9797
- **MCP Server:** https://docs.htmlcsstoimage.com/integrations/mcp/
9898
- **n8n Integration:** https://docs.htmlcsstoimage.com/integrations/n8n/
9999
- **TypeScript Client (npm):** https://docs.htmlcsstoimage.com/example-code/typescript/
100+
- **Python Client (PyPI):** https://docs.htmlcsstoimage.com/example-code/python/
101+
- **PHP Client (Packagist):** https://docs.htmlcsstoimage.com/example-code/php/
102+
- **.NET Client (NuGet):** https://docs.htmlcsstoimage.com/example-code/c/
100103
- **HTTP Proxies:** https://docs.htmlcsstoimage.com/guides/advanced/proxies/
101104
- **Storage Destinations:** https://docs.htmlcsstoimage.com/guides/advanced/storage-destinations/ — Includes individual setup guides for Amazon S3, Cloudflare R2, Backblaze B2, DigitalOcean Spaces, Wasabi, Google Cloud Storage, and other S3-compatible services.
102105
- **Jumbo Images:** https://docs.htmlcsstoimage.com/guides/advanced/jumbo-images/
@@ -115,6 +118,9 @@ Use OG Image Configs for social cards tied to existing public pages. Use the sta
115118
- **n8n:** https://docs.htmlcsstoimage.com/integrations/n8n/
116119
- **MCP Server:** https://docs.htmlcsstoimage.com/integrations/mcp/
117120
- **TypeScript Client (npm):** https://docs.htmlcsstoimage.com/example-code/typescript/
121+
- **Python Client (PyPI):** https://docs.htmlcsstoimage.com/example-code/python/
122+
- **PHP Client (Packagist):** https://docs.htmlcsstoimage.com/example-code/php/
123+
- **.NET Client (NuGet):** https://docs.htmlcsstoimage.com/example-code/c/
118124

119125
## Code Examples Available
120126

‎parameters/format.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ See the [signed image URL guide](/getting-started/create-and-render/) for URL co
140140
| [.NET](/example-code/c/) | `0.12.0` | `Format = RenderImageFormat.PDF` |
141141
| [TypeScript](/example-code/typescript/) | `0.9.0` | `format: 'pdf'` |
142142
| [Ruby](/example-code/ruby/) | `0.3.0` | `format: "pdf"` |
143+
| [Python](/example-code/python/#official-pypi-client) | `0.2.0` | `format="pdf"` |
144+
| [PHP](/example-code/php/#official-composer-client) | `0.1.0` | `format: ImageFormat::PDF` |
143145

144146
For choosing a format and retrieving an existing image with a different extension, see the [file formats guide](/guides/styling/file-formats/).
145147

0 commit comments

Comments
 (0)