To capture a website from PHP on Debian, run an installed Chrome or Chromium binary with its headless and screenshot options through PHP’s proc_open(). On PHP 7.4 and later, pass the command as an argument array to avoid shell parsing. Chrome writes screenshot.png to its working directory; set that directory explicitly and check the process exit code and error output.
What you need on Debian
- A Chrome or Chromium executable that runs on your Debian release and architecture.
- PHP with
proc_open()available. - An output directory writable by the user running PHP.
- A reachable page URL and enough time for its content to render.
Debian Reference lists Chromium, but package availability, version and installation commands depend on the Debian release and architecture. Check the Debian Reference and the package information for the system you are deploying to rather than assuming a universal apt command or binary path. Chrome and Chromium may have different executable names and locations, so make the path configurable.
Locate the browser executable
On the target host, check which executable is installed and use its full path in the PHP configuration. For example, run command -v chromium or command -v google-chrome in a shell where the PHP service environment is representative. These are lookup examples, not guaranteed paths or installation instructions. If PHP runs under a service account or container, verify the browser is available in that same environment.
Capture a viewport screenshot from PHP
The following PHP 7.4+ example starts Chrome directly, closes the unused standard input pipe, collects output and errors, and reports a nonzero exit status. Set $chrome, $url and $outputDir for your deployment.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errors#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
<?php
declare(strict_types=1);
$chrome = '/path/to/chrome-or-chromium';
$url = 'https://example.com/';
$outputDir = '/absolute/path/to/output';
$command = [
$chrome,
'--headless',
'--screenshot',
'--window-size=1280,900',
$url,
];
$descriptors = [
0 => ['pipe', 'r'],
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$pipes = [];
$process = proc_open($command, $descriptors, $pipes, $outputDir);
if (!is_resource($process)) {
throw new RuntimeException('Could not start Chrome');
}
fclose($pipes[0]);
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
$exitCode = proc_close($process);
if ($exitCode !== 0) {
throw new RuntimeException("Chrome failed with exit code $exitCode: $stderrn$stdout");
}
echo "Screenshot saved to $outputDir/screenshot.pngn";
PHP’s argument-array form of proc_open() is documented for PHP 7.4 and later; it starts the executable without a shell, avoiding shell interpretation of arguments. See the PHP proc_open() manual. The example is a starting point, not a verified deployment-specific script: confirm the executable, directory permissions and Chrome runtime dependencies on your host.
Choose the viewport and output location
--window-size=1280,900 sets the viewport dimensions for the capture. Change the width and height to match the layout you need. Chrome’s CLI screenshot option writes screenshot.png in the current working directory; the fourth argument to proc_open() above sets that directory explicitly. Ensure it exists and is writable before launching Chrome. See the Chrome Headless command-line reference.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Use a capture deadline thoughtfully
Chrome’s --timeout option sets the maximum time in milliseconds before screenshot, DOM-dump or PDF capture proceeds, even if the page is still loading. It is a deadline, not proof that a page has reached the state you want. A page may load images, fonts or script-driven content later, or keep animating. If timing matters, choose a deadline for the site and verify the resulting image; there is no universal readiness test established by the CLI option.
PHP before version 7.4
Older PHP versions require a command string for proc_open(). Quote each individual argument with escapeshellarg(); do not concatenate untrusted input into a shell command. For example:
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
<?php
$chrome = '/path/to/chrome-or-chromium';
$url = 'https://example.com/';
$parts = [
escapeshellarg($chrome),
escapeshellarg('--headless'),
escapeshellarg('--screenshot'),
escapeshellarg('--window-size=1280,900'),
escapeshellarg($url),
];
$command = implode(' ', $parts);
// Pass $command to proc_open() with the same descriptors and output handling
// as the PHP 7.4+ example. Set proc_open()'s working directory to $outputDir.
escapeshellarg() quotes a single shell argument; it is not a general command sanitizer. Prefer the array form when PHP 7.4 or newer is available. See the PHP escapeshellarg() manual.
Viewport capture is not full-page capture
The basic --screenshot command captures the page viewport. Making the viewport unusually tall does not guarantee that the entire document will appear: lazy-loaded content may not have loaded, and the page may extend beyond the chosen dimensions. Full-page screenshots require additional handling, such as scrolling and coordinating capture or using browser automation/protocol commands. The Chrome CLI reference documents the basic screenshot behavior; do not treat --window-size alone as a full-page setting.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Chrome Headless and headless-shell
Chrome’s current unified Headless mode runs without a visible browser UI while sharing the browser implementation with headful Chrome. Chrome says this unified mode has been used since version 112. The older, separate Headless implementation has been offered as a standalone chrome-headless-shell binary beginning with Chrome 132.0.6793.0. Chrome characterizes the full browser as the more authentic, feature-complete choice for high-accuracy testing; the older shell has fewer dependencies and may suit simpler automated screenshots. Confirm which executable you installed before using it in PHP. Read Chrome’s Headless mode documentation.
Troubleshooting
- PHP cannot start the process: Check that the configured executable exists and is executable by the PHP service account. Verify the path in the same environment where PHP runs.
- Chrome starts but exits with an error: Inspect captured stderr and the exit code. Check runtime dependencies and permissions for the host and browser profile/environment; the exact cause depends on the deployment.
- No screenshot appears: Chrome writes to its current working directory. Confirm
$outputDirexists, is writable by PHP, and that you are looking forscreenshot.pngthere. - The image is clipped:
--window-sizesets the viewport, not a promise of full-document capture. Use a full-page capture method if the entire page is required. - The image is blank or incomplete: A successful process launch does not ensure the page finished rendering. Adjust the capture deadline for the target page and inspect whether its content depends on delayed scripts, fonts, network requests or animations.
- The command works in a shell but not in PHP: PHP may run with a different user, path, permissions or environment. Test the executable and output directory under the PHP service account.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. A GET request returns an image or PDF; here is a cURL example that saves a WebP screenshot of the example URL:
Recommended Free Tools
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/ -o shot.webp
See the ScreenshotNeo documentation for API parameters and setup. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.
Frequently Asked Questions
What filename does Chrome use for a CLI screenshot?
The --screenshot option writes screenshot.png in Chrome’s current working directory.
Does --window-size make the screenshot full-page?
No. It sets the viewport dimensions; capturing the full document requires additional handling.
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.

