No browser runtime to maintain
Avoid provisioning Chrome and long-running browser processes in PHP web or queue workers.
HTML to PNG with PHP
No browser management required
Render HTML and CSS from PHP without installing Chrome, running a PHP headless-browser wrapper, or building a separate image-storage pipeline.
PHP workflow
Adjust the HTML and CSS here, then use the PHP example below instead of recreating the browser-rendering workflow locally.
Managed rendering
Keep the application code focused on the request and response while HCTI manages Chromium, render isolation, retries, and hosted output.
Avoid provisioning Chrome and long-running browser processes in PHP web or queue workers.
Use managed browser versions, isolated render jobs, built-in timing controls, and consistent viewport behavior across deployments.
Receive the hosted .png result without building a separate pipeline for temporary files, uploads, storage, and delivery.
HTML to image API
POST the HTML, CSS, and format from PHP. HCTI handles the browser lifecycle and returns the generated .png URL.
Send complete markup and styles, including browser-supported fonts, images, SVG, and JavaScript.
Set format to png and use the hosted .png URL returned by the API.
Set viewport dimensions and device scale, or crop the result to a CSS selector.
Choose light or dark mode, timezone, and screen or print media.
How it works
Submit the content with format set to png and any viewport or browser settings.
The API loads the markup, styles, fonts, and assets in a managed browser environment.
Embed the hosted result, download the file, or save it in your own storage and application records.
Output formats
Keep the same HTML and CSS. Choose lossless detail, compact compatibility, modern web delivery, or a paginated document.
Looking to capture a webpage as PNG? Explore URL to PNG in PHPSmaller files and broad compatibility for photography, previews, and content-heavy pages.
Explore JPEGStrong visual quality, transparency, and modern compression for web delivery.
Explore WebPPaginated documents with page sizing, margins, backgrounds, and print styles.
Explore PDFExample code
Copy a complete PHP request. Authentication, HTML, CSS, viewport settings, and response handling are shown together.
<?php
$request = [
"html" => <<<'HCTI_HTML'
<div class="card">
<h1>Hello, world!</h1>
<p>Generated from HTML and CSS.</p>
</div>
HCTI_HTML,
"css" => <<<'HCTI_CSS'
.card {
width: 480px;
padding: 40px;
background: #f0fdf4;
color: #052e16;
font-family: sans-serif;
}
HCTI_CSS,
"format" => "png",
];
$curl = curl_init("https://hcti.io/v1/image");
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_USERPWD => sprintf("%s:%s", getenv("HCTI_API_ID"), getenv("HCTI_API_KEY")),
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode($request, JSON_THROW_ON_ERROR),
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($curl);
if ($response === false) {
throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
if ($status >= 400) {
throw new RuntimeException(sprintf("HCTI request failed (%d): %s", $status, $response));
}
$result = json_decode($response, true, 512, JSON_THROW_ON_ERROR);
printf("%s\n", $result["url"]);
Ready to render?
Send HTML and CSS to the API and receive a hosted .png image URL without running browser infrastructure.