Use wkhtmltoimage directly first; add xvfb-run only if your installed build or package needs an X server. The upstream project describes its tools as headless, but wrapper guidance and some package-specific deployments still use Xvfb. The reliable approach is to identify the binary and version, test a simple render on the target server, and use the virtual display wrapper if that test shows a display dependency.
What Xvfb does—and when you need it
wkhtmltoimage converts a web page or local HTML file into an image. Xvfb provides a virtual X display: it lets programs that expect a display server run without a physical monitor or desktop session. It is not a universal prerequisite for wkhtmltoimage. The upstream project describes its tools as running headlessly without a display service, while IMGKit says some headless servers may need Xvfb. A Debian deployment example uses xvfb-run for its package built against unpatched Qt. Those statements concern different builds and packaging contexts, not one rule for every Linux installation. The project homepage and IMGKit README describe the distinction.
Run the binary without Xvfb before adding a wrapper. If it produces the expected image, there is no reason to add Xvfb to that command. If it fails because no display is available, try Xvfb and compare the result. Check the target binary’s own help and man page because available options and packaging vary by distribution and release.
Check the installed binary and version
First confirm that the executable exists and that your shell resolves the one you intend to run:
Free tools Windows power users keep installed
One-click scans. No signup required.
#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.
command -v wkhtmltoimage
wkhtmltoimage --version
wkhtmltoimage --help
If your application uses IMGKit, its README documents configuring explicit paths for both wkhtmltoimage and xvfb-run when they are not in PATH. A command available in an interactive shell may not be visible to a service, container, or scheduled job running with a different environment.
Distribution package versions are not uniform. The Ubuntu Jammy manual documents package version 0.12.6-2; the Bionic manual documents 0.12.4-1. These are examples from different Ubuntu releases, not a promise about what is currently installed on your server. Check the package and manual for the server’s own release. See the Jammy manual and Bionic manual.
Render once without Xvfb
The basic command takes options followed by an input and output path. For a website, try:
wkhtmltoimage https://example.com page.png
The same invocation can use a local HTML file as input:
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.
wkhtmltoimage ./page.html page.png
Check that the output exists and is a valid image before wiring the command into a script. If this succeeds on the server under the same account and environment used by your application, it is already operating headlessly; Xvfb is unnecessary for this capture.
Install and run with Xvfb when the build needs a display
Install the distribution’s Xvfb package
Install the package provided for the specific Linux distribution and release. IMGKit gives xvfb as its Ubuntu package example and xorg-x11-server-Xvfb as its CentOS example. Package names and installation instructions may differ across releases, so check the target distribution’s package documentation rather than assuming these names apply everywhere. IMGKit’s examples and wrapper guidance are in its README.
Wrap the capture command
Use xvfb-run to start a virtual display for the child process. The -a option asks the wrapper to select an available display number:
xvfb-run -a wkhtmltoimage https://example.com page.png
For local input, the same wrapper pattern applies:
xvfb-run -a wkhtmltoimage ./page.html page.png
Run the wrapped command as the same user that will perform production captures. If the wrapper itself is missing, check whether the distribution package installed it and whether its directory is in the service’s PATH. When using IMGKit, configure the explicit path to xvfb-run if needed.
Recommended Free Tools
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.
Set rendering options deliberately
The installed binary’s --help and man page are the authority for its supported flags. The Ubuntu Jammy manual documents these controls:
- Dimensions:
--widthand--heightset the screen dimensions used for rendering. Set them to suit the layout you want to capture. - Format and quality:
--formatselects the output image format and--qualitycontrols image quality where supported. Confirm the chosen format and quality behavior in the installed version’s manual. - JavaScript:
--javascript-delaywaits after page load, which can help when a page populates content after its initial load.--disable-javascriptprevents page JavaScript from running; use it only when the page does not need scripts to render the desired content. - Local resources:
--disable-local-file-accessand--allowcontrol local-file access. Do not enable local-file access unless the capture needs it. Grant only the access required for the intended local resources. - Load errors:
--load-error-handlingand--load-media-error-handlingcontrol handling of page and media load failures. Consult the manual for accepted values in the installed build.
These options are documented in the Ubuntu Jammy wkhtmltoimage manual. Do not assume every distribution’s binary supports identical flags just because a current manual lists them.
Troubleshoot failed or incorrect captures
The command says it cannot connect to a display
This indicates the current build or package is attempting to use an X display in this environment. Try the same command under xvfb-run -a. If it then works, keep the wrapper in the deployment path and confirm that both xvfb-run and wkhtmltoimage are discoverable by the production process.
xvfb-run is not found
The wrapper may not be installed, or the process’s PATH may not include its location. Install the appropriate Xvfb package for the distribution or configure the full executable path. IMGKit documents explicit paths for the executable and wrapper in its README.
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
The image is blank, incomplete, or missing dynamic content
Check that the input URL is reachable from the server and that the output path is writable. If content is created by JavaScript, verify that JavaScript is enabled and use an appropriate --javascript-delay. Set width and height to match the layout being tested. For local HTML that references files, inspect the local-file access flags and grant only what the render requires.
The render fails on a page or media resource
Use the installed manual’s page and media error-handling options to choose the behavior appropriate to the job. A screenshot pipeline that should reject incomplete output should not silently treat missing media as a successful capture. Test error handling against the actual pages and resources your service processes.
A wrapper reports a command failure or segmentation fault
IMGKit recommends running the command it reports directly when its wrapper reports a command failure. This helps separate a wrapper/configuration problem from a failure in the executable. The README notes that some wkhtmltoimage versions can fail with segmentation faults, but that does not establish one cause for every crash. Record the exact version, command, input, and error, then investigate compatibility for that specific build.
Version compatibility and server security
The project downloads page calls 0.12.6 the stable series and gives its release date as June 11, 2020. It lists operating systems, distributions, and architectures for its downloads, which are hosted through GitHub releases. Treat that as the project’s stated release information, not a guarantee that a package fits a newer server release or architecture. Check the specific download and test it in the target environment: wkhtmltopdf downloads.
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 reinstallCrashes, 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 minuteBest 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.
There is an important security boundary if your service renders user-controlled pages or HTML. The project warns: “Do not use wkhtmltopdf with any untrusted HTML – be sure to sanitize any user-supplied HTML/JS, otherwise it can lead to complete takeover of the server it is running on!” The warning appears on the project’s downloads page. Do not treat rendering as a safe way to inspect arbitrary supplied HTML or JavaScript; sanitize inputs and follow the project’s security guidance.
Or skip the browser setup
If you need screenshots of public web pages rather than a locally controlled wkhtmltoimage process, ScreenshotNeo offers a one-request API and an MCP server for AI agents. Its API can return a screenshot as PNG, JPEG, WebP, or a PDF. For example, this cURL request captures a page as WebP:
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. It removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server gives AI agents tools including take_screenshot, get_page_info, and capture_pdf. 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.
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 →Sources and scope
The command syntax and options cited here follow the Ubuntu Jammy manual; Ubuntu Bionic is included to illustrate package-version differences. Xvfb guidance is conditional and based on the IMGKit README and the package-specific Debian deployment example, not a claim that every build needs a virtual display. Confirm behavior and flags against the binary installed on your server.
Frequently Asked Questions
Does wkhtmltoimage always need Xvfb on a headless Linux server?
No. The upstream project describes its tools as headless, while some builds or packages may require an X server. Test the installed binary first and use xvfb-run if its behavior requires a display.
Can I use Xvfb with a local HTML file as input?
Yes. Wrap the same local-file command with xvfb-run -a, and check local-resource access settings if the page references files.
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.

