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
Chromium

How to Convert HTML to PNG on Ubuntu

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

For a quick local conversion, run wkhtmltoimage input.html output.png. For modern CSS and JavaScript, use headless Chromium with --screenshot. Chromium generally matches current browser rendering more closely; wkhtmltoimage is convenient when its older rendering engine is sufficient.

Choose the renderer before you convert

Your choice affects whether scripts run, how modern CSS is interpreted, what local files can be read, and how precisely you control the viewport.

Method Best for JavaScript and modern CSS Main controls Important limitation
wkhtmltoimage Simple HTML files and repeatable CLI jobs Supported, but uses its own older rendering stack Width, height, delay, crop, zoom, quality, headers and cookies Local-file access is restricted by default; complex modern layouts may differ from Chrome
Headless Chromium or Chrome Pages that depend on current browser behavior Uses the browser engine and executes page scripts Viewport size and screenshot output Headless command-line flags vary by installed release
ImageMagick Resizing or converting an image after rendering Does not render HTML or CSS Resize, composite and image-format operations It is post-processing, not an HTML renderer

The practical recommendation is to start with Chromium for a script-heavy page or current CSS. Use wkhtmltoimage when its direct input/output workflow and options fit your document. This is a capability-based choice, not a published speed or success-rate benchmark.

Prepare the HTML file and output directory

  1. Save the document with a complete HTML structure and explicit CSS dimensions where possible.
  2. Use an absolute path when opening a local file. For example, /home/alex/site/input.html.
  3. Keep the output directory writable and decide whether the image should represent a fixed viewport or the whole document.
  4. Check that referenced stylesheets, images and fonts are reachable from the renderer. Relative URLs should resolve relative to the HTML file or page URL.

For a local document, an absolute URL has the form file:///home/alex/site/input.html. Three slashes are required before the absolute path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Audio Converter - Edit and convert your sound and music files to other audio formats - easy audio editing software - compatible with Windows 10, 8 and 7
  • AUDIO ALL-ROUNDER – convert your audio or video files into almost any audio format - edit, trim, merge, adjust sample and bit rate, extract audio from videos
  • Supported input formats - MP3, MP2, AAC, AC3, WAV, WMA, M4A, RM, RAM, OGG, AU, AIF, AIFF, PG, MPEG, MPEG 2, MP4, M4V, MJPG, MJPEG, HD TS, HD MTS, HD M2TS, HD MPG, HD MPEG, HD MP4, HD WMV, QuickTime HD MOV and others
  • Supported output formats - AAC, AC3, AIFF, AMR, AU, FLAC, M4A, MKA, MP2, MP3, OGG, WAV, WMA
  • EASY TO INSTALL AND USE - user-friendly and intuitive interface, free tech support whenever you need assistance
  • compatible with Windows 10, 8 and 7 (32 and 64-bit versions) - single user license

Method 1: convert HTML with wkhtmltoimage

Install and verify it

Ubuntu Jammy documents wkhtmltoimage as an HTML-to-image converter and lists package/manpage version 0.12.6-2. On an Ubuntu system using the standard package repositories, install the package that supplies the command, then verify the binary:

sudo apt update
sudo apt install wkhtmltopdf
wkhtmltoimage --version

Package availability and versions can differ outside Jammy, so treat 0.12.6-2 as the Jammy documentation version rather than a promise about every Ubuntu release.

Basic local conversion

wkhtmltoimage input.html output.png

The command accepts the input file first and the output file second. If you do not provide a height, the output height is calculated from the page content. That is useful for a long document, but a fixed height is preferable when every generated image must have the same dimensions.

Set viewport, delay and image loading

wkhtmltoimage 
  --width 1280 
  --height 2000 
  --javascript-delay 1000 
  --enable-javascript 
  --images 
  input.html output.png
  • --width and --height define the rendering area.
  • --javascript-delay 1000 waits 1,000 milliseconds before capture. It can help content that appears shortly after initial parsing.
  • --enable-javascript enables script execution.
  • --images enables image loading.

A delay is not a universal readiness test. A page may still be fetching data after the chosen interval, or it may never finish because a request failed. For pages with a reliable completion signal, wkhtmltoimage also documents --window-status, which can be used when the page sets the expected window status.

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

Control cropping, scale and quality

The Ubuntu manpage also documents --crop-w, --crop-h, --zoom and --quality. Cropping is useful when the HTML contains a large canvas but you need only a region; zoom changes the rendered scale before the image is written; quality affects formats that expose a quality setting. Keep the output dimensions explicit when a downstream process expects a fixed size.

Rank #2
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
  • Convert your PDF files into Word, Excel & Co. the easy way
  • Convert scanned documents thanks to our new 2022 OCR technology
  • Adjustable conversion settings
  • No subscription! Lifetime license!
  • Compatible with Windows 11, 10, 8.1, 7 - Internet connection required

Allow local CSS, fonts and images safely

Local-file access is restricted by default. If the page needs assets in a known directory, allow only that directory:

wkhtmltoimage 
  --allow /home/alex/site/assets 
  /home/alex/site/input.html output.png

Use the narrowest asset directory that works. Explicitly enabling unrestricted local access is broader than necessary and can expose files that the page was not meant to read. If a stylesheet or font remains missing, confirm both its path and the renderer process’s permissions.

Pass headers or cookies when the page requires them

The manpage documents custom headers and cookies. This is useful for a page that needs an authentication cookie or a request header before it returns its final markup. Do not place long-lived credentials in shell history or a shared build log; provide them through the secret-management mechanism used by your CI system.

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

Method 2: use headless Chromium or Chrome

Capture a local HTML file

Chrome’s headless documentation defines --screenshot and recommends pairing it with --window-size:

chrome --headless=new 
  --screenshot 
  --window-size=1280,2000 
  file:///home/alex/site/input.html

The browser writes screenshot.png in the current working directory. If your workflow needs a different filename, rename it after the command:

Rank #3
Roxio Easy VHS to DVD 3 Plus | VHS, Hi8, V8 Video to DVD or Digital Converter | Amazon Exclusive 2 Bonus DVDs [Windows Disc]
  • Convert your VHS tapes to DVD or digital to enhance and preserve your home movies
  • Capture analog video directly from your camcorder or VCR and burn to DVD or convert to popular digital formats to share freely across devices
  • Trim video, make quick edits, enhance color, add transitions, reduce noise and stabilize old footage to breathe new life into your old videos
  • Complete your video experience by selecting from creative, customizable DVD menu templates, or creating personalized disc labels
  • Get 2 DVDs for your first projects: An Amazon exclusive extra
mv screenshot.png /home/alex/site/output.png

Depending on your installation, the executable may be named chromium, google-chrome or another vendor-specific name. Substitute the binary that is installed and inspect its --help output if a flag is rejected.

Capture a remote page

chrome --headless=new 
  --screenshot 
  --window-size=1280,2000 
  https://example.com/

Headless Chromium processes the page as a browser does, including JavaScript that changes the DOM. Chrome’s --dump-dom documentation describes the same processing model: scripts run, the resulting DOM is parsed, and the serialized result is produced. That makes Chromium the safer choice when the screenshot depends on current browser APIs or client-side layout.

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

Account for the M132 headless change

The Chromium headless documentation notes that, from M132, the old headless implementation is no longer part of the Chrome binary. Current deployments may require the separate chrome-headless-shell. If --headless=new fails, check the installed browser version and its package documentation rather than copying flags from an older machine.

Wait for asynchronous content

The basic screenshot CLI does not define one universal selector-wait or network-idle flag. A fixed delay may work for a predictable page, but it can also capture too early or waste time. For an application that renders after an API call, use a browser-automation flow based on the DevTools protocol or a browser library and wait for the page’s actual ready condition, such as a selector that appears only after the data is present. Keep that readiness condition specific to the page; “wait one second” is not equivalent to “the page is ready.”

Render then post-process with ImageMagick

ImageMagick’s format reference covers PNG/APNG and many other image operations. Use it after HTML rendering, not as the renderer itself. For example, resize a Chromium or wkhtmltoimage result to a maximum width while preserving its aspect ratio:

Rank #4
DIGITNOW USB 2.0 Audio Capture Card,Cassette Converter,Cassette to Digital,Cassette to MP3 Converter,Support Mac & Windows 10/8.1/8 / 7 / Vista/XP
  • USB audio grabber with 3.5mm and R/L audio connector input, via usb connected to pc, recording audio into computer and convert to MP3/WAV
  • Audio Capture Card, Plug and play, no extra power supply. Easy to record from Microphone/Line In/Auxiliary input
  • Coming with professional audio capture/converting software ( Audacity) and online updating
  • Easily recording live audio or transfer analog to be digital formats such as MP3, WAV. User can save & listen to music on MP3 player, computer, portable CD player, or car stereo or home stereo system
  • Supporting OS: Windows 10 / 8.1 / 8 / 7 / Vista / XP, Mac OS 10.11 and more.
magick screenshot.png -resize 1600x output.png

This separation makes failures easier to diagnose: first confirm that the HTML renderer produced the expected pixels, then apply resizing, compositing or format conversion.

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

Dimensions, fidelity and repeatability

Pick a viewport deliberately

Responsive CSS can produce a different layout at 800 pixels and 1,280 pixels. Set --width and --height in wkhtmltoimage or --window-size in Chromium whenever the image is part of a test, documentation build or visual diff. For a full-page capture, allow the renderer to calculate the content height or use a sufficiently large height, then crop in a post-processing step if the consumer requires a fixed canvas.

Expect renderer differences

wkhtmltoimage and Chromium do not share a rendering stack. Fonts, flexbox behavior, newer CSS features and script timing can therefore produce different pixels. If a desktop browser is your visual reference, Chromium is generally the closer starting point because it uses the current browser engine. This is a practical inference from the documented capabilities, not a benchmark result.

Make builds deterministic

  • Pin the browser or package version used by CI.
  • Install the same fonts on every runner.
  • Keep viewport dimensions and output paths explicit.
  • Wait for a page-specific ready condition before capture.
  • Record the renderer version with the generated artifact.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

The PNG is blank or shows stale content

  • For wkhtmltoimage, increase --javascript-delay only after confirming that the page eventually renders.
  • Use a page-specific ready signal with browser automation when content arrives asynchronously.
  • Check that the input URL or file:// path points to the intended file.

CSS, images or fonts are missing

  • Resolve relative URLs from the document’s actual location.
  • Confirm file permissions for the user running the command.
  • With wkhtmltoimage, add a narrowly scoped --allow /absolute/path/to/assets.
  • For remote assets, verify that the renderer can reach the host and that the resource does not require a missing header or cookie.

The dimensions are wrong

  • Set wkhtmltoimage’s --width and --height.
  • Set Chromium’s --window-size=width,height.
  • Crop the result afterward with ImageMagick when the page’s natural height is larger than the required canvas.

The result differs from Chrome on your desktop

Try Chromium headless first. wkhtmltoimage uses a separate rendering stack, so identical HTML does not guarantee identical pixels.

Chromium rejects a headless flag

Inspect the installed version and run the binary’s --help. The M132 transition removed the old headless implementation from the Chrome binary; a separate chrome-headless-shell may be the appropriate executable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
GINGIN AV to HDMI Converter, AV to HDMI Adapter Support 720p/1080p for PS1/PS2/PS3/Xbox 360/WII/N64/SNES/STB/VHS/VCR/Blue-Ray DVD Players
  • Composite to HDMI Converter: Converts analog AV composite (Yellow, White, Red) input to HDMI 720P/1080P (60HZ) output, displayed on smart TV, Projector or HD Display, which bring back your old and cherish memories.
  • Plug to Play: This HDMI Converter no extra drivers need, just plug and play,easy to use. Please hook up the USB Power Cable (included) to 5V power source during use. Note: The Video Converters only support converts AV to HDMI, can't converts HDMI to AV.
  • Widely Used: This composite to hdmi adapter is widely applied to PS1, PS2, PS3, Xbox, N64, Wii, STB, VHS, VCR, DVD Players and other devices with standard composite AV input. Note: It can only be used when PS2 is set to RGB output.
  • Wide Compatibility: This Video Audio Converter Adapter supports source formats of PAL, NTSC3.58, NTSC4.43, SECAM, PAL/M, PAL/N standard TV. Provide advanced signal processing with great precision, colors, resolutions, and details. Important Note: This converter can't improve video quality!
  • Attention & Package: Please ensure to connect this av hdmi converter to power source to make it work. Package include: 1*AV to HDMI Adaptor, 1*USB Power Cable(adapter not included), 1*User Manual.

A local file cannot read an unrelated directory

That restriction is expected in wkhtmltoimage. Move required assets below one project directory and allow only that directory, rather than granting broad filesystem access.

Or skip the browser setup

If the page is available at a URL, ScreenshotNeo returns a PNG, JPEG, WebP or PDF through one GET request. Its cleanup steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be disabled. Clean shots are the only billable results: bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers.

See the ScreenshotNeo API documentation for all options. The following examples use https://example.com; replace only the target URL and your API key.

cURL

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

Python

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

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' }); const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also provides an MCP server for Claude, Cursor and other MCP clients, with take_screenshot, get_page_info and capture_pdf tools. Its 63 options include full-page capture with lazy-image loading, CSS-selector element capture, dark mode, device presets, custom viewports, retina scale, PDF paper and margin controls, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector/delay/network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

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.
Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free, and every feature is available on every plan. The API examples target a URL, so a private local file must first be made reachable at a URL; use wkhtmltoimage or Chromium directly when the file must remain local. Create a free ScreenshotNeo account to get 1,000 screenshots a month without a card.

FAQ

Is wkhtmltoimage 0.12.6-2 the version on every Ubuntu release?

No. That number is the version listed in the Ubuntu Jammy documentation. Check the package and manpage for the Ubuntu release you actually deploy.

Can ScreenshotNeo capture a file that exists only on my Ubuntu computer?

Not through the URL-based example above. A local-only file should be rendered with wkhtmltoimage or Chromium; ScreenshotNeo is appropriate after the page is available at a reachable URL.

Frequently Asked Questions

Is wkhtmltoimage 0.12.6-2 the version on every Ubuntu release?

No. That number is specific to the Ubuntu Jammy documentation; check the package for your installed Ubuntu release.

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

Can ScreenshotNeo capture a file that exists only on my Ubuntu computer?

No. The API captures a reachable URL, while a local-only file should be rendered with wkhtmltoimage or Chromium.

Quick Recap

Bestseller No. 1
Bestseller No. 2
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
PDF Converter Ultimate - Convert PDF files into Word, Excel, PowerPoint and others - PDF converter software with OCR recognition compatible with Windows 11 / 10 / 8.1 / 8 / 7
Convert your PDF files into Word, Excel & Co. the easy way; Convert scanned documents thanks to our new 2022 OCR technology
$29.99
Bestseller No. 3
Roxio Easy VHS to DVD 3 Plus | VHS, Hi8, V8 Video to DVD or Digital Converter | Amazon Exclusive 2 Bonus DVDs [Windows Disc]
Roxio Easy VHS to DVD 3 Plus | VHS, Hi8, V8 Video to DVD or Digital Converter | Amazon Exclusive 2 Bonus DVDs [Windows Disc]
Convert your VHS tapes to DVD or digital to enhance and preserve your home movies; Get 2 DVDs for your first projects: An Amazon exclusive extra
$51.96
Bestseller No. 4
DIGITNOW USB 2.0 Audio Capture Card,Cassette Converter,Cassette to Digital,Cassette to MP3 Converter,Support Mac & Windows 10/8.1/8 / 7 / Vista/XP
DIGITNOW USB 2.0 Audio Capture Card,Cassette Converter,Cassette to Digital,Cassette to MP3 Converter,Support Mac & Windows 10/8.1/8 / 7 / Vista/XP
Coming with professional audio capture/converting software ( Audacity) and online updating
$13.99

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 *

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.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
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.