Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To generate a webpage snapshot or thumbnail in PHP, use a browser automation library that launches Chrome or Chromium, loads the page, waits for it to render, and saves an image. For direct PHP control, chrome-php/chrome is a straightforward route. Choose a fixed viewport for a thumbnail, an element or clip for a focused crop, or a full-page capture when you need content below the fold.
Choose the output before choosing the PHP library
A snapshot can mean several different things. Decide what the destination needs: a fixed frame, a particular component, or the entire document. These produce different image dimensions and should not be treated as interchangeable.
| Use case | Capture method | What to plan for |
|---|---|---|
| Thumbnail showing the page as it appears in a frame | Set an explicit viewport width and height | Choose dimensions and format to fit the thumbnail slot. A browser’s default viewport may not match your destination. |
| One chart, card, or section | Capture a page element or a clipped region | Use a stable selector or coordinates, and allow the target content to render before saving. |
| Reference image preserving below-the-fold content | Capture the full page | The resulting image can be very tall and large; full-page output is not automatically a good thumbnail. |
The examples below use chrome-php/chrome because it exposes browser operations directly to PHP. It still requires Chrome or Chromium on the machine that runs the script; installing only a Composer package is not enough.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Install chrome-php/chrome and its browser
The project README lists PHP 7.4–8.5 and Chrome/Chromium 65 or newer as requirements, and documents Linux testing with macOS and Windows compatibility. These are the project’s stated compatibility claims, not an independent guarantee for every operating system image or deployment. Check the project README for current requirements before setting up a production host.
#1 Best Overall
-
Install the Composer dependency from your PHP project directory:
composer require chrome-php/chrome -
Install Chrome or Chromium using the method appropriate for your operating system or deployment image. Confirm the browser executable is available to the PHP process, not merely to an interactive shell.
-
If Chrome is not on the expected path, configure the browser factory with the executable path supported by the version of the library you installed. Check the package documentation for the option name and syntax for that version.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Run the capture as the same user and in the same environment as the application. Production containers, workers, and web-server users can have different browser paths and permissions from a developer’s workstation.
Generate a basic screenshot in PHP
This example navigates to a URL, waits for navigation, writes a PNG, and closes the browser even if capture fails:
Rank #2
<?php
require __DIR__ . '/vendor/autoload.php';
use HeadlessChromiumBrowserFactory;
$url = 'https://example.com';
$output = __DIR__ . '/page.png';
$browserFactory = new BrowserFactory();
$browser = $browserFactory->createBrowser();
try {
$page = $browser->createPage();
$page->navigate($url)->waitForNavigation();
$page->screenshot()->saveToFile($output);
} finally {
$browser->close();
}
Change $url to the page you want and $output to a writable location. The example captures the browser page using the library’s default page settings; for a predictable thumbnail, set the viewport deliberately before capture using the API supported by your installed package version. The project README also documents JPEG and WebP output, quality settings, clipped screenshots, and full-page capture.
For a web application, avoid writing user-controlled URLs to arbitrary filesystem paths. Validate or constrain the URL, choose an application-controlled output directory, and generate a safe filename. If the resulting images are public, consider whether the page might contain private or personalized content before exposing the file.
Set viewport, crop, format, or full-page output
Fixed viewport for a thumbnail
A thumbnail usually represents a page inside a known frame. Set the browser viewport to the intended capture width and height before navigating or taking the screenshot, using the viewport API documented by your installed version. Then save the image in a format appropriate to its use: PNG for lossless output, or JPEG/WebP when those formats better suit the delivery requirements. The library documentation describes all three formats and JPEG/WebP quality options.
Viewport dimensions define what is visible in the browser frame; they do not necessarily define the final rendered image dimensions when device scale or other capture settings are involved. Verify the actual output dimensions in your own application before relying on them in a layout.
Capture one element or a clipped region
If the image should show a chart or card rather than the entire page, capture the element or a clipped region. Element capture focuses the output on a page component; clipping uses a region of the rendered page. Prefer an element-based target when page layout shifts could make hard-coded coordinates unreliable. Wait until the target exists and is rendered before taking the image.
Capture the full page
A full-page screenshot extends beyond the current viewport to include content below the fold. The chrome-php/chrome documentation describes full-page capture using a full-page clip. This is useful for reference or archival images, but the resulting file can be unusually tall and large. If the consumer expects a small thumbnail, use a viewport capture or crop instead.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Wait for the state you actually need
Waiting for navigation means the browser has reached the navigation condition used by the library; it does not guarantee that every delayed image, animation, or client-rendered widget is ready. For pages that populate content after initial navigation, wait for the relevant selector or other page condition using the mechanisms available in your chosen library. When the target page depends on external services, test what happens if those requests are slow or unavailable.
Other PHP-oriented routes
Spatie Browsershot for URL or HTML conversion
Spatie Browsershot offers a higher-level interface for converting a URL or supplied HTML into an image or PDF. Its README describes rendering through Puppeteer running headless Chrome, so this route involves a Node/Puppeteer and browser stack in addition to PHP. It can suit an application that wants a conversion-oriented API rather than direct control over browser objects.
The Browsershot README mentions an older v2 Chrome CLI path for environments without Node/Puppeteer, but states that v2 is no longer maintained. Do not treat that legacy route as the default current setup.
Playwright PHP when browser automation is already part of the project
Playwright PHP’s screenshot guide describes viewport, full-page, and element screenshots. Its examples include Composer and browser installation commands and state PHP 8.2 or newer and Node.js 20 or newer for the documented setup. That means it is not simply a PHP-only dependency: account for its documented Node and browser requirements as well.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #4
Choose among these routes based on the runtime you can support and the control your capture needs. The project documentation describes different dependency stacks and interfaces; it does not establish one package as universally best.
Deploying captures reliably
- Confirm runtime dependencies: install the browser and any Node/Puppeteer components required by the chosen route in the production environment.
- Check paths and permissions: the worker or web-server account needs access to the browser executable, temporary files, and destination directory.
- Close resources: close the browser in a
finallyblock so exceptions do not leave browser processes behind. - Choose an explicit destination: use a stable writable directory and ensure the application can serve the saved image if that is part of the workflow.
- Test the target environment: pages can render differently with different browser versions, fonts, network access, cookies, and authentication state. Validate the result on the actual host.
- Set realistic expectations: image size and capture time depend on the page and environment. A full document, slow assets, or blocked network requests can change the result; no performance figure is established by the cited project documentation.
Troubleshooting common failures
Chrome or Chromium cannot be found
Cause: the browser is missing, installed in a nonstandard location, or not visible to the account running PHP. Fix: install the browser in the deployment image, verify the executable path as the application user, and configure that path using the option documented for your installed library version.
The script works locally but fails on the server
Cause: production may have different PHP/browser versions, permissions, fonts, or network access. Fix: compare the host’s runtime against the package’s stated requirements, install browser dependencies in the deployment environment, and run a minimal capture as the same service account.
The screenshot is blank or missing late-loading content
Cause: navigation completed before the relevant client-rendered content or assets were ready, or the page failed to load them. Fix: wait for the specific element or page state needed, confirm that the browser can reach the required resources, and check whether the target page requires cookies or authentication.
The thumbnail is the wrong size or includes too much page
Cause: the script used an unintended viewport, a full-page capture, or a crop that does not match the destination. Fix: set an explicit viewport for a frame, select the intended element or clip for a focused image, and reserve full-page capture for content that needs to extend below the fold.
Output cannot be saved
Cause: the destination directory does not exist or is not writable by the PHP process. Fix: create an application-controlled output directory, grant the service account the necessary write access, and use an absolute path when diagnosing the issue.
Or skip the browser setup
If you would rather make one HTTP request than install and operate a browser stack, ScreenshotNeo accepts a URL and returns a screenshot or PDF. Its API supports PNG, JPEG, and WebP. Cookie banners are accepted like a visitor would accept them, and more than 60 known consent platforms, newsletter popups, and chat widgets are removed before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, with the outcome indicated by X-Page-Verdict and X-Billed response headers. ScreenshotNeo also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.
For a PHP application, call the endpoint with cURL from your runtime or use an HTTP client. This cURL example saves a WebP screenshot of a URL; replace the example URL and provide your API key:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options and response details. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Can I capture a webpage as a PDF instead of an image?
Yes. Browsershot documents URL or HTML conversion to PDF, and ScreenshotNeo’s API and MCP tools also support PDF capture.
Can PHP libraries capture a page supplied as HTML rather than a public URL?
Browsershot documents both URL input and supplied HTML input. For other libraries, check the current package documentation for the supported navigation and content APIs.
Which PHP screenshot package is universally best?
None is established as universally best. Choose according to the browser/runtime stack you can deploy and whether you need direct browser control, conversion-oriented URL/HTML handling, or Playwright automation.
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.

