October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Chrome

How to Convert HTML to PNG on Linux: Chrome, Playwright, and wkhtmltoimage

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The best Linux method depends on what you are rendering. Use headless Chrome or Chromium for a one-off URL, Playwright when you need a repeatable script and browser controls, and wkhtmltoimage for a concise local-file conversion. All three can produce PNG files, but they do not guarantee identical rendering. For pages where modern browser behavior, consent handling, reliable failure reporting, or API access matters, ScreenshotNeo provides a one-request alternative.

Choose the right HTML-to-PNG method

HTML is not an image format. A renderer must load the document, apply CSS, execute any permitted JavaScript, fetch assets, and rasterize the resulting page. On Linux, the practical choices documented for this task are:

Need Route What the documentation establishes
One direct URL capture Chrome or Chromium headless The command-line interface supports --screenshot and window-size settings.
Repeatable automation or precise controls Playwright The Page API can navigate and save a PNG; scale can be CSS pixels or device pixels.
Simple local HTML conversion wkhtmltoimage Ubuntu’s Jammy manual documents an input/output command and local-file permission controls.

Do not assume that one renderer is universally more faithful. Browser engines, JavaScript timing, fonts, viewport dimensions, and asset availability all affect the output. If exact visual reproduction matters, compare the result with the browser and page behavior you actually need to reproduce.

Method 1: Convert a URL with headless Chrome or Chromium

Chrome’s headless command-line reference documents the --screenshot flag. Its documented behavior is to save screenshot.png in the current working directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Lenovo Business Laptop - Linux Mint (Cinnamon) - Intel i5-1335U, 16GB RAM, 256GB SSD, 15.6" FHD 1920x1080 Display, Full Keyboard, Fast Charging
  • Intel Core i5-1335U Processor (12M Cache, 12 Threads, up to 4.6 GHz) - 256GB Solid State Drive - 16GB DDR4 SDRAM
  • 15.6" FHD (1920x1080) Non-Touch Anti-Glare Display - Intel UHD 620 Integrated Graphics - Stereo Speakers
  • 720p HD Webcam with Privacy Shutter. Integrated Microphone - Intel Dual Band Wireless-AC (2x2) 8265, Bluetooth Version 4.2
  • I/O Ports: 2x USB 3.0, 1x USB 3.1 Type-C 3.1, Headphone/Mic Combo Port, 4-in-1 Card Reader, HDMI, Kensington Mini-Lock Slot
  • Linux Mint (Cinnamon) 64-Bit - Keyboard with Full NumberPad - Fast Charging

Basic URL screenshot

  1. Confirm the executable name on your distribution. It may be google-chrome, google-chrome-stable, chromium, or another package-specific name.
  2. Run the headless command from the directory where you want the output:
google-chrome --headless --disable-gpu --screenshot https://example.com

If your installation uses Chromium, substitute its executable name:

chromium --headless --disable-gpu --screenshot https://example.com

The result is normally screenshot.png in the current directory. Validate the exact flags against the Chrome or Chromium build installed on your Linux system; distributions can package different executable names and versions.

Set the viewport size

Use --window-size=WIDTH,HEIGHT when the page is responsive and you need a deterministic viewport:

google-chrome --headless --disable-gpu --window-size=1440,900 --screenshot https://example.com

This captures the target page at a 1,440 by 900 viewport. A viewport is not the same as a full-page capture: content below the visible area may not appear unless the particular Chrome build and command-line options you use support a full-page workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When the CLI is a good fit

  • A single public URL or a small number of manual captures.
  • A shell script where browser automation is unnecessary.
  • Situations in which you can install and invoke a compatible Chrome or Chromium binary directly.

Method 2: Use Playwright for scripted PNG screenshots

Playwright is the most flexible option when conversion is part of a build, test, reporting, or batch process. Its Page API documents navigation followed by page.screenshot(); the PNG format is inferred from the .png extension.

Install Playwright on Linux

Install the Node.js package in a project, then install the browser binaries and Linux dependencies using Playwright’s current installation instructions. For a headless-only setup, the documentation describes:

npx playwright install --with-deps --only-shell

Browser downloads occupy hundreds of megabytes by default and are stored in an operating-system-specific cache. Check disk space and consult the current Playwright browser documentation for the requirements of your distribution and release.

Complete JavaScript example

Create a project and install Playwright:

mkdir html-to-png
cd html-to-png
npm init -y
npm install playwright
npx playwright install --with-deps --only-shell

Save this as capture.js:

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage({
    viewport: { width: 1440, height: 900 },
    deviceScaleFactor: 1
  });

  await page.goto('https://example.com', { waitUntil: 'networkidle' });
  await page.screenshot({ path: 'page.png', fullPage: true });
  await browser.close();
})();

Run it with:

node capture.js

The fullPage: true option asks Playwright to include the page’s full scrollable content. For a local HTML file, use a file URL:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
HP 17 Business Laptop - Linux Mint Cinnamon - Intel Quad-Core i5-10210U, 32GB RAM, 1TB PCIe NVMe SSD + 1TB Storage HDD, 17.3" Inch HD+ (1600x900) Display
  • Intel Core i5-10210U (up to 4.2GHz) - 1TB PCIe NVMe + 1TB HDD - 32GB DDR4 SDRAM
  • 17.3" HD+ (1600x900) Display, Intel UHD Graphics 620
  • Built in HD 720p Webcam with Microphone - Bluetooth Version4.2
  • I/O Ports: 2x USB 3.1 (Data Only), 1x USB 2.0, 1x HDMI, 1x Headphone/Microphone Combo Jack
  • Linux Mint Cinnamon 64-Bit - 6-Row Keyboard w/ Full Numberpad
const path = require('path');
const fileUrl = 'file://' + path.resolve('index.html');
await page.goto(fileUrl, { waitUntil: 'load' });
await page.screenshot({ path: 'index.png', fullPage: true });

Local pages that reference other files must use paths that the browser process can read. If assets are generated asynchronously, wait for a meaningful selector or an application-specific readiness signal rather than assuming the initial load event means the page is visually complete.

Choose the output scale

Playwright documents two scale choices. CSS scale produces one output pixel per CSS pixel. Device scale uses device pixels and can create a larger image on high-density displays. Set the browser context or page’s device scale factor deliberately when image dimensions matter:

const context = await browser.newContext({
  viewport: { width: 1200, height: 800 },
  deviceScaleFactor: 2
});
const page = await context.newPage();

Use a factor of 1 for predictable CSS-pixel dimensions; use a higher factor when you intentionally need a denser raster. Record the setting alongside the image so later captures remain comparable.

Capture an HTML string

For generated markup, set the page content instead of navigating to a URL:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.setContent(`<!doctype html>
<html><body><h1>Report</h1></body></html>`, {
  waitUntil: 'load'
});
await page.screenshot({ path: 'report.png' });

External stylesheets, web fonts, images, and scripts still need reachable URLs or locally available files. A screenshot can be technically successful while missing an asset that failed to load, so inspect the page and logs when fidelity is important.

Method 3: Convert a local file with wkhtmltoimage

Ubuntu’s Jammy manual describes wkhtmltoimage as an HTML-page-to-image converter and gives this invocation form:

wkhtmltoimage [OPTIONS]... <input file> <output file>

Basic conversion

For a local document:

wkhtmltoimage index.html index.png

The cited Jammy manual identifies package version 0.12.6-2. Package availability and behavior can differ on other distributions, so check your distribution’s current package documentation before installing or scripting around this tool.

Permit local assets explicitly

When the input is a local file, the manual warns that access to other local files is not allowed unless explicitly permitted with --allow. If index.html refers to a stylesheet or image in an asset directory, allow that directory:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Panasonic Toughbook CF-31 MK5 Rugged Laptop, 13.1in i5, 8GB 256GB (Renewed)
  • [ULTRA-RUGGED DESIGN] MIL-STD-810G and IP65 certified. Built to survive 6-foot drops, heavy rain, and extreme vibrations. Features a magnesium alloy chassis with an integrated carry handle for maximum portability
  • [4G LTE - WORK ANYWHERE] Integrated 4G LTE Multi-Carrier Mobile Broadband. Stay connected to the internet in remote areas or on the road without relying on Wi-Fi or phone hotspots. True mobile freedom for field professionals
  • [1200-NIT SUNLIGHT READABLE] 13.1" XGA Touchscreen with CircuLumin technology. At 1200 nits, it is nearly 4x brighter than a standard laptop, ensuring perfect visibility under direct, intense sunlight
  • [LINUX UBUNTU PRE-INSTALLED] Fast, secure, and bloatware-free. Optimized for developers, network engineers, and diagnostic software that thrives in a stable, open-source environment
  • [LEGACY SERIAL PORT] Features a native RS-232 Serial Port, HDMI, and USB 3.0. Essential for connecting directly to industrial machinery, CNCs, and automotive diagnostic tools without unreliable adapter
wkhtmltoimage --allow /home/user/site/assets index.html index.png

Keep the allowed path as narrow as practical. Without it, the command may produce an image with missing CSS, images, or fonts even though it exits as if the conversion completed.

When to choose it

  • Your source is a local HTML file and you want a short command.
  • You can work within the converter’s local-file security model.
  • You do not need Playwright’s browser scripting, page lifecycle controls, or scale API.

Handling local files, assets, and dynamic pages

Local CSS and images

Use absolute, readable paths or a predictable project directory. For Playwright, a file:// URL can load local content subject to browser file-access behavior. For wkhtmltoimage, explicitly authorize directories with --allow. Verify that relative URLs resolve from the document’s location.

JavaScript-rendered content

A static converter may capture the DOM before an application finishes rendering. In Playwright, wait for a selector that indicates readiness, a known delay, or a suitable navigation condition:

await page.goto('https://example.com/dashboard', { waitUntil: 'domcontentloaded' });
await page.waitForSelector('[data-rendered="true"]');
await page.screenshot({ path: 'dashboard.png', fullPage: true });

Choose a condition tied to your page rather than an arbitrary delay whenever possible. Network-idle waiting can also remain unresolved on pages with long-lived connections, so use it only when it matches the application.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fonts and reproducibility

Different Linux machines can have different installed fonts and browser versions. For repeatable output, keep the renderer version, viewport, scale, input files, and asset versions consistent. If a page depends on remote fonts, allow enough time for them to load and verify that the resulting text has the expected metrics.

Performance, reliability, and cost considerations

Startup and batching

Launching a browser is more expensive than issuing a simple file conversion. For multiple pages, keep one Playwright browser process open and create pages or contexts as needed instead of launching a new browser for every image. Limit concurrency to what the machine’s CPU, memory, and page complexity can sustain.

Output dimensions and memory

Full-page captures and high device-scale factors increase image dimensions and memory use. Start with CSS scale and a defined viewport, then increase the scale only when the downstream use requires it. Very long pages may need a design that captures sections separately.

Failure handling

Make scripts fail visibly: set navigation timeouts, catch exceptions, close the browser in a finally block, and check that the output file exists and has a nonzero size. A renderer can return an image while the page itself is blank or missing assets, so add application-level checks where the image is used in a pipeline.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Lenovo V15 Gen 4 - Business Laptop - AMD Ryzen 5 7430U - 15.6" FHD Display - 8GB RAM - 512GB SSD Storage - Integrated AMD Radeon™ Graphics - Webcam Privacy Shutter - Business Black
  • THE POWER TO STAY PRODUCTIVE – Looking to make your everyday work and home life more manageable without breaking the bank? The Lenovo V15 Gen 4 offers long-term reliability with top-of-the-line features to make you your most productive self.
  • CRUSH YOUR TO-DO LIST – The AMD Ryzen CPU pairs quiet performance and enhanced operating power to crush your high-demand workday. It optimizes performance and allows for seamless multitasking.
  • TRUE-TO-LIFE VISUALS – The 15.6” FHD IPS display is anti-glare with 300 nits brightness to see your best outside or in. Its 88% screen-to-body ratio makes viewing detailed applications like spreadsheets a breeze.
  • SEAMLESS COLLABORATION – Lenovo Smart Appearance enhances your camera effects to protect your privacy and to make you the focus of every video conference. Intelligent noise cancelation minimizes distraction and Dolby Audio provides an elegantly sonorous experience.
  • BUILT TO WITHSTAND – Built for military-grade toughness, the V15 Gen 4 is tested to withstand harsh temperatures, pressure, humidity, vibrations and more. Keep your work safe from the board room to your living room and everywhere in between.

Troubleshooting common Linux conversion problems

“Command not found”

Cause: the executable is not installed or has a different name. Fix: locate the installed Chrome/Chromium binary, install the package for your distribution, or use Playwright, which installs its supported browser binaries separately.

Playwright reports missing libraries or browser launch failure

Cause: browser binaries or operating-system dependencies are absent. Fix: run the documented installation command, including --with-deps where appropriate, then verify available disk space and the requirements for your Linux distribution.

PNG is blank or content is missing

Cause: the page is still rendering, a script failed, a resource URL is inaccessible, or a local file was blocked. Fix: wait for a readiness selector, inspect console and network errors, confirm asset paths, and use --allow for authorized local directories with wkhtmltoimage.

The image is the wrong size

Cause: responsive layout, window dimensions, full-page behavior, or device scale differs between runs. Fix: set an explicit viewport or --window-size, choose CSS or device scale deliberately, and state whether you need the viewport only or the full scrollable page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remote pages time out

Cause: slow resources, long-lived connections, DNS or network restrictions, or a page that never reaches the chosen lifecycle condition. Fix: set a realistic timeout, wait for a specific selector instead of indefinite network idle, and test the URL from the same Linux host that performs the capture.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF, so you can request a PNG without installing Chrome, Chromium, Playwright, or their Linux dependencies.

For the complete parameter list and current API behavior, see the ScreenshotNeo documentation. This cURL example writes a PNG-compatible image response to disk:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same request in Python:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

And in Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = require('fs');
fs.writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

Adapt the target URL and request output options as described in the documentation. ScreenshotNeo can accept cookie or consent banners before capture and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed as clean shots, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP server includes take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Other controls include full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF settings, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector or delay waits, network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, selectable-TTL caching, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameters commonly used by other screenshot APIs also work, which can simplify migration.

Best Value
Lenovo IdeaPad Slim 3 Linux Laptop, 15.6" FHD Touchscreen Laptop, 8-Core AMD Ryzen 7 5825U, 16GB RAM, 512GB SSD, Keypad, SD Card Reader, Stylus Pen + External Portable SSD + USB Hub, Linux Ubuntu OS
  • Powerful Linux Laptop: This IdeaPad Slim 3 Laptop comes pre-installed with Ubuntu Linux, offering fast performance, robust security, and a clean, user-friendly experience. Enjoy full customization, seamless hardware compatibility, and access to thousands of open-source apps. Whether you're working, creating, or coding, it's built to keep up with everything you do.
  • A Multitasking Master: The latest AMD Ryzen 7 5825U processor (up to 4.5 GHz) delivers powerful performance with 8 cores and 16 threads for smooth multitasking. Integrated AMD Radeon Graphics provide crisp visuals for streaming, browsing, photo editing, and casual gaming. With smart machine intelligence, it adapts to your needs for a fast, responsive experience.
  • 15.6" Full HD Display: The IdeaPad Slim 3 boasts an 88% screen-to-body ratio for a floating, edge-to-edge visual experience. TÜV Low Blue Light certification reduces eye strain, making it perfect for long work or study sessions.
  • Military-Grade Durability: The smart IdeaPad Slim 3 combines portability and durability, letting you work, study, and play on the go. With a profile 10% slimmer than the previous generation, it's lightweight yet military-grade rugged, ready for anything, anywhere.
  • Versatile Connectivity: Enjoy the security of a built-in webcam with a privacy shutter. Connect effortlessly with multiple ports: 2x USB A, 1x USB C, 1x HDMI, 1x SD Card Reader, 1x Headphone/Microphone combo. Bundle comes with Stylus Pen, 256GB Portable SSD and 5-in-1 Docking Station.

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to start without a card.

FAQ

Can I convert HTML to PNG without a display server?

Yes. Chrome/Chromium headless mode and Playwright’s headless browser are designed to run without a visible desktop window. You still need the browser binary and any required Linux libraries.

Should I use PNG or another format?

PNG is appropriate when you need lossless output or crisp text and interface details. The Linux tools described here target PNG output; ScreenshotNeo can also return JPEG, WebP, or PDF when those formats better fit your pipeline.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why does my local stylesheet work in a browser but not in wkhtmltoimage?

The converter’s local-file security rules may block access to referenced files. Grant the required asset directory with --allow and verify that the paths resolve from the input document.

Frequently Asked Questions

Can I convert HTML to PNG without a display server?

Yes. Chrome/Chromium headless mode and Playwright’s headless browser run without a visible desktop window, provided the browser binary and required Linux libraries are installed.

Should I use PNG or another format?

PNG is useful for lossless text and interface detail. ScreenshotNeo can additionally return JPEG, WebP, or PDF when those formats suit the pipeline better.

Why does a local stylesheet work in a browser but not in wkhtmltoimage?

The converter may block referenced local files. Use the documented –allow option for the needed asset directory and verify paths relative to the input document.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.