Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →To convert HTML to an image in PHP, use Spatie Browsershot to render the page in headless Chrome and save a PNG or JPEG. PHP supplies the HTML and controls the capture; the browser does the rendering, so a local setup needs Node.js, Puppeteer, and Chrome as well as the PHP package. If you would rather not maintain that runtime, a hosted screenshot API is another option.
Choose the right HTML input
Browsershot provides different entry points depending on where the markup lives. Use a URL for a page the browser can reach, an HTML string for markup generated in PHP, and a file path for a saved HTML document.
Capture a web page
<?php
require __DIR__ . '/vendor/autoload.php';
use SpatieBrowsershotBrowsershot;
Browsershot::url('https://example.com')
->save(__DIR__ . '/page.png');
The output extension selects the image format for an image capture. Use .png for PNG or .jpg for JPEG; PDF output is selected by a path ending in .pdf. See Browsershot’s image creation documentation for the supported capture controls.
Capture an HTML string
<?php
require __DIR__ . '/vendor/autoload.php';
use SpatieBrowsershotBrowsershot;
$html = '<!doctype html>
<html>
<head><meta charset="utf-8"><title>Report</title></head>
<body><h1>Monthly report</h1><p>Generated by PHP.</p></body>
</html>';
Browsershot::html($html)
->save(__DIR__ . '/report.png');
When the HTML references images, stylesheets, fonts, or scripts by URL, Chrome must be able to reach those resources. For predictable output, use valid markup and ensure the assets are available from the machine that runs the browser.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
Capture a local HTML file
<?php
require __DIR__ . '/vendor/autoload.php';
use SpatieBrowsershotBrowsershot;
Browsershot::htmlFromFilePath(__DIR__ . '/report.html')
->save(__DIR__ . '/report.png');
A local file is convenient when another part of the PHP application has already written the document to disk. Check relative asset paths: a stylesheet or image reference that worked in a browser at another location may not resolve from this file.
Install the PHP package and browser runtime
Browsershot is a PHP wrapper around Puppeteer, which controls headless Google Chrome. Installing the Composer package alone does not install the rendering engine. The machine or container that runs PHP also needs a compatible Node.js, Puppeteer, and Chrome setup, and the PHP process must be able to launch it.
Packagist listed Browsershot 5.4.0 on May 26, 2026, with PHP ^8.2 and dependencies including ext-fileinfo, ext-json, spatie/temporary-directory, and symfony/process. Package metadata changes; check the current Packagist listing and the version-specific documentation before pinning a release.
- Install the package with Composer:
composer require spatie/browsershot. - Install and configure Node.js, Puppeteer, and Chrome for the environment where the PHP code will run, following the current Browsershot setup documentation.
- Run a small capture from the same user and environment as your application. This exposes missing executables, permissions, or runtime dependencies before the capture is added to a request or job.
The Browsershot README points people unable to install Node and Puppeteer to its v2 release, but explicitly says v2 is no longer maintained. Its older PhantomJS-based v1 is described as abandoned, so neither should be treated as a current default.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Set the image dimensions and capture area
Decide what the image should contain before tuning the browser. A viewport capture represents the visible browser frame; a full-page capture extends to the document’s full height; an element capture isolates a chosen part of the page. These choices affect image dimensions and, for long pages, memory use and processing time.
Rank #2
Set a viewport
Use windowSize(width, height) to choose the browser viewport in pixels. A larger viewport can change responsive layout, so choose dimensions that match the target use rather than enlarging the image after capture.
Browsershot::url('https://example.com')
->windowSize(1440, 900)
->save(__DIR__ . '/desktop.png');
Capture the full page or one element
Browsershot documents full-page capture and element selection. Full-page capture is useful for a long article or report; selecting an element is useful for a card, chart, or invoice within a larger page. If the target selector does not match, the intended element cannot be isolated; confirm the markup and selector before changing the viewport.
// Full-page image
Browsershot::url('https://example.com')
->fullPage()
->save(__DIR__ . '/full-page.png');
// Capture a selected element
Browsershot::url('https://example.com')
->select('.report-card')
->save(__DIR__ . '/report-card.png');
Choose image type, quality, and scale
PNG is suitable when you want lossless output; JPEG is a lossy option whose quality can be set explicitly. The image documentation also covers device scale settings, which affect output resolution relative to CSS pixels. Higher scale can produce a sharper image but also a larger file. Use the documented screenshot type and quality methods for the installed Browsershot version, and inspect the result at its intended display size.
Wait for content before saving
A page’s initial load event does not guarantee that every visible item is ready. JavaScript may add content later, lazy-loaded images may wait for scrolling, and web fonts can change text layout after the first paint. An early capture can therefore be blank, incomplete, or misaligned.
- Use
waitUntilNetworkIdle()when you need to let network activity settle, particularly for assets such as fonts and images. - Use a delay when the page has a known, predictable rendering pause.
- Wait for a selector or function when a specific component signals that the page is ready.
- For lazy-loaded imagery, use full-page capture where appropriate and verify that the page has actually loaded the images before saving.
Waiting for network idle can also take longer on pages with persistent network requests. Prefer a meaningful selector or bounded delay when the page never becomes idle. The image creation documentation describes the available wait controls.
Or skip the browser setup:
ScreenshotNeo is a hosted screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF, so PHP does not need to launch a local Chrome installation for the capture. Create an API key and use the API base URL; the code and parameter details are in the ScreenshotNeo documentation.
<?php
$accessKey = 'YOUR_API_KEY';
$url = 'https://stripe.com';
$query = http_build_query([
'access_key' => $accessKey,
'url' => $url,
]);
$ch = curl_init('https://api.screenshotneo.com/v1/shot?' . $query);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 90,
]);
$image = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($image === false || $status < 200 || $status >= 300) {
throw new RuntimeException('Screenshot request failed: ' . $error . ' (HTTP ' . $status . ')');
}
file_put_contents(__DIR__ . '/shot.webp', $image);
- Cookie banners, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers report the page verdict and whether the request was billed.
- An MCP server exposes screenshot tools for AI clients, including Claude, Cursor, and other MCP clients.
- The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
Recommended Free Tools
Use a hosted PHP rendering SDK instead
If you prefer an SDK over a direct screenshot endpoint, HTML to Image documents a hosted PHP integration that accepts HTML or public URLs and renders on its infrastructure. Its PHP documentation lists PHP 8.3 or newer, Guzzle, cURL, and an API key as requirements. The service handles browser execution, but your application now depends on the provider, credentials, network access, and its terms.
Asset reachability is a key difference: the hosted renderer must be able to fetch referenced resources. Its documentation warns that resources on your application’s localhost are not reachable from its servers. This approach suits markup and assets that can be made reachable from the service; it is not a direct substitute for rendering private local files without making those inputs available to the renderer.
The vendor documentation describes 50 starting credits, an offer that may change. Check the current HTML to Image PHP SDK documentation for present terms rather than assuming that allowance is still available.
Rank #4
Choose local rendering or a service
| Consideration | Browsershot on your server | Hosted renderer |
|---|---|---|
| Where the browser runs | Your environment, through Puppeteer and Chrome. | The provider’s infrastructure. |
| Setup responsibility | Install and maintain the PHP package and compatible Node/Puppeteer/Chrome runtime. | Maintain the SDK or API integration, API key, and network access; browser operations are hosted. |
| Input reachability | Can render markup or files available to the application and URLs reachable from its browser. | Must be able to reach the supplied URL and its assets from the provider’s renderer; localhost resources are not reachable for HTML to Image. |
| Capture controls | Browsershot documents viewport sizing, full-page and selected-element capture, image type and quality, scale, and wait controls. | Controls depend on the service and SDK documentation. |
| External dependency | Local browser runtime and its system dependencies. | Third-party service, account, API key, network connection, and provider terms. |
Troubleshoot common capture failures
PHP runs, but no image is produced
Confirm that Composer’s autoloader is included and that the PHP process can execute the configured Node, Puppeteer, and Chrome binaries. A command that works in an interactive shell may fail under a web-server or queue-worker account because it has a different PATH or permissions. Run the capture as the same account and in the same container or deployment environment as the application.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteThe image is blank or missing late-loading content
Check that the destination URL is reachable from the rendering machine and that scripts and assets load without authentication or network errors. Add a wait condition suited to the page, such as network idle or a selector that appears only when the needed content is ready. For lazy images, ensure the page actually triggers their loading before the capture.
The layout is clipped or unexpectedly responsive
Set the viewport explicitly and decide whether you want viewport, full-page, or element capture. A responsive page may render a mobile layout at a narrow width even if the output file is later displayed large. If clipping persists, confirm the target element’s dimensions and whether the page has finished changing layout before capture.
Fonts or image assets are missing
Verify each asset URL from the renderer’s environment. A path that resolves on a developer’s machine may not exist in a container or hosted rendering environment. Wait for assets to load before capture; if using a hosted service, do not rely on resources available only at localhost.
The hosted SDK cannot load a private or local page
A hosted renderer cannot fetch an application’s private local resources unless they are made reachable to it. Use local Browsershot when the page or assets must remain inside your environment, or arrange an appropriately reachable input consistent with the service’s security and access requirements.
Performance, reliability, and cost considerations
With Browsershot, rendering time and resource use depend on the page, asset loading, capture dimensions, and whether you wait for network activity to settle. Full-page captures and higher output scales can produce larger files and require more work than a viewport image. When handling user-triggered or batch captures, run them in a controlled worker rather than letting slow pages hold ordinary web requests open; set an application-level timeout and handle failures explicitly.
Local rendering avoids a per-request external rendering service but requires browser installation, updates, and operational capacity on your own servers. A hosted renderer reduces that maintenance burden, while adding a network and provider dependency. Compare the actual service plan and terms before estimating recurring costs: the HTML to Image documentation’s starting-credit offer is mutable, and the cited documentation does not establish a permanent price for the service.
For both approaches, treat captured pages as untrusted input if users can supply URLs or HTML. Restrict what your application is allowed to render and consider the network access available to the browser or hosted renderer; otherwise a screenshot feature may expose internal resources or consume resources on unexpectedly slow pages.
Frequently Asked Questions
Can PHP convert HTML to PNG without installing Chrome?
Not with Browsershot’s local rendering route: it uses Puppeteer and headless Chrome. A hosted rendering API can move browser execution off your PHP server, but then the service must be able to access the input and referenced assets.
Free tools Windows power users keep installed
One-click scans. No signup required.
Can I save the result as JPEG instead of PNG?
Yes. Browsershot’s image documentation supports JPEG with an explicit screenshot type and quality setting; use an image path with a JPEG extension and verify the relevant method for your installed version.
Does Browsershot render PHP templates directly?
Browsershot renders HTML, not PHP source code. Have PHP generate the markup first, then pass the resulting string with `html()` or save it and use `htmlFromFilePath()`.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

