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

Direct answer: install a compatible wkhtmltoimage build, invoke it from C# with System.Diagnostics.Process, pass the page URL and output filename, then check both the exit code and the generated file. For applications that need a native in-process integration, use the documented libwkhtmltox image API through P/Invoke. wkhtmltoimage uses Qt WebKit, so it is useful for controlled rendering but should not be treated as a current Chrome engine.

What wkhtmltoimage does

wkhtmltoimage is the image-rendering command-line tool in the wkhtmltopdf project. It renders a URL or local HTML file to an image without requiring a display service. The project describes the tools as open-source LGPLv3 command-line programs using the Qt WebKit rendering engine. The documented command shape is:

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

The installed executable determines the exact formats and switches available. Ubuntu Jammy packages identify a 0.12.6-2 build; verify the version and package provenance on your target operating system before deployment.

Choose an integration path

Path Best for Important trade-off
Child process Services, workers and simple deployments Requires an executable and native runtime outside your .NET process.
P/Invoke Applications needing the native library lifecycle directly Requires correct DLL selection, marshaling and callback/disposal code.
.NET wrapper Teams that prefer a managed API Package maintenance, native assets and release status must be checked.

Prerequisites and installation checks

  • Install a build of wkhtmltoimage for the operating system and CPU architecture running your service.
  • Run wkhtmltoimage --version under the same account as the service and record the result.
  • Confirm the service account can execute the binary and write to the destination directory.
  • If rendering local HTML, identify the asset directories that must be allowed explicitly.
  • Test the target URL from the server. DNS, TLS, proxy and firewall behavior can differ from a developer workstation.

Recommended C# implementation: invoke the executable

This pattern starts a process, captures diagnostics, waits for completion and verifies the output. It deliberately treats the listing as an implementation pattern: the command-line contract is documented, but no particular C# sample is guaranteed by the project.

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.

Complete example

using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;

public static class WkhtmlToImage
{
public static async Task RenderAsync(string executable, string url, string outputPath)
{
Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(outputPath))!);

var psi = new ProcessStartInfo
{
FileName = executable,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
psi.ArgumentList.Add("--enable-javascript");
psi.ArgumentList.Add("--javascript-delay");
psi.ArgumentList.Add("1500");
psi.ArgumentList.Add("--format");
psi.ArgumentList.Add("png");
psi.ArgumentList.Add(url);
psi.ArgumentList.Add(outputPath);

using var process = new Process { StartInfo = psi };r> process.Start();
Task<string> stdout = process.StandardOutput.ReadToEndAsync();
Task<string> stderr = process.StandardError.ReadToEndAsync();
await process.WaitForExitAsync();
string diagnostic = (await stderr) + (await stdout);

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

if (process.ExitCode != 0)
throw new InvalidOperationException($"wkhtmltoimage failed ({process.ExitCode}): {diagnostic}");
if (!File.Exists(outputPath) || new FileInfo(outputPath).Length == 0)
throw new InvalidOperationException("The process succeeded but no non-empty image was created.");
}
}

Call it from a worker or controller with a fully qualified executable path:

await WkhtmlToImage.RenderAsync("/usr/bin/wkhtmltoimage", "https://example.com", "/var/tmp/example.png");

On Windows, use the installed executable path such as C:toolswkhtmltoimage.exe. Keep URL and output arguments in ArgumentList; do not concatenate untrusted strings into a shell command.

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

Settings that affect the rendered image

JavaScript and timing

JavaScript is enabled by default in many builds, but set the behavior explicitly when reproducibility matters. Use --disable-javascript for static pages, or --enable-javascript --javascript-delay 1500 when the page fills its DOM asynchronously. A delay is a fixed wait, not a guarantee that a framework or API request has finished; increase it only after measuring the page’s behavior.

Images and local assets

Use the image-loading switch documented by your build when you need to disable or enable remote images. Local HTML often needs local-file access and, for security, an explicit allow-list such as --allow /srv/site/assets. Without it, CSS, fonts or images may appear missing even though the HTML itself loads.

Viewport, dimensions and crop

Set a viewport width and height for responsive layouts. Width and height control the rendered page area; crop coordinates select a subregion after rendering. A full-page image may still depend on how the WebKit build calculates document height, so test pages with long, lazy or overflowing content.

Cookies, headers and authentication

Pass cookies and custom HTTP headers using the switches supported by the installed build. Treat exported session cookies and authorization headers as secrets, avoid logging them, and isolate jobs that render private pages. A header accepted by your origin may not be applied to every subresource, so verify the resulting image.

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

Output and error handling

Use an explicit output extension and, where supported, an output-format option for PNG or JPEG. Enable logging while diagnosing remote failures and configure load-error handling according to whether a missing page should fail the job or produce a partial image. Always inspect the exit code and file size.

Using the native library with P/Invoke

The official libwkhtmltox image binding exposes a high-level C interface in image.h. Its lifecycle is:

  1. Call wkhtmltoimage_init.
  2. Create global settings with wkhtmltoimage_create_global_settings.
  3. Set UTF-8 string settings.
  4. Create a converter with wkhtmltoimage_create_converter.
  5. Add page or object content.
  6. Call wkhtmltoimage_convert.
  7. Destroy the converter and shut down native state when the process is finished with it.

A production binding must declare the correct native calling convention and character marshaling, retain delegates for the entire conversion, copy unmanaged output safely, and load the DLL matching the process architecture. Native initialization and teardown are process-wide concerns; do not assume that an arbitrary wrapper is thread-safe. Serialize access unless the wrapper and build explicitly document concurrent converters.

Using a .NET wrapper

AdaskoTheBeAsT.WkHtmlToX describes a C# wrapper for wkhtmltopdf, including HTML-to-image conversion and a dedicated native execution thread. The captured NuGet page labels version 13.0.0 as unreleased, so verify the current package status, native assets, supported operating systems and maintenance before pinning it. A wrapper can simplify marshaling, but it does not remove the need to ship compatible native binaries.

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

When Chromium is a better engine

CoreHtmlToImage 2.0.0 is documented as a .NET converter for HTML strings and URLs using headless Chromium; its examples include asynchronous conversion, PNG/JPG/WebP output, quality, viewport dimensions, full-page capture and transparent backgrounds. Version 2.0 replaces wkhtmltoimage with headless Chromium. Chromium generally provides a newer web platform than Qt WebKit, but package behavior, browser-runtime download and deployment requirements must be verified for the version you select.

Consideration wkhtmltoimage Chromium-based alternative
Rendering engine Qt WebKit Headless Chromium
Integration Executable, native library or wrapper Managed API with browser-runtime dependencies
Useful controls JavaScript delay, cookies, headers, local access, crop and format Viewport, full page, quality, transparency and async APIs documented by the package
Compatibility Older web-platform behavior is possible Closer to current browser behavior, subject to package version

Reliability, security and performance

  • Use a per-job temporary output path and atomically move a verified file into its final location.
  • Apply an outer process timeout and terminate stuck workers; a JavaScript delay alone is not a timeout policy.
  • Limit concurrent processes according to CPU and memory capacity. No authoritative performance benchmark is established here.
  • Run as a low-privilege account, restrict writable directories and allow only required local paths.
  • Validate schemes and destination paths when URLs or filenames come from users. Never let a rendering endpoint become an unrestricted server-side request proxy.
  • Cache identical captures when freshness permits, and include viewport, cookies, headers and rendering settings in the cache key.

Troubleshooting

“The system cannot find the file”

The service cannot resolve the executable or a native dependency. Use an absolute path, install the matching architecture and run the command as the service account.

Exit code is non-zero and the image is absent

Read redirected stderr. Check DNS, TLS, proxy rules, authentication, output permissions and the URL’s load-error behavior. Reproduce the exact command on the server, not on a workstation.

Blank or partially rendered image

Increase JavaScript delay, confirm JavaScript is enabled, wait for a page-specific condition where your build supports one, and inspect failed asset requests. For local content, enable only the required directories.

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

Missing fonts, CSS or images

Check relative URLs, certificate access and local-file restrictions. A successful HTML response does not prove every subresource was reachable.

Modern site layout differs from Chrome

This is an engine limitation: wkhtmltoimage uses Qt WebKit. Try a Chromium-based converter when the page depends on newer CSS, JavaScript or browser APIs.

Intermittent hangs

Set a process-level timeout, capture diagnostic output, cap concurrency and isolate pages that never finish network activity. Do not leave orphaned renderer processes running indefinitely.

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. One GET request returns PNG, JPEG, WebP or PDF, while its capture flow accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before the shot. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and each response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers.

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

See the complete parameter reference in the ScreenshotNeo documentation. cURL:

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

Python:

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

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}`);

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.

It also provides an MCP server with take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. Features include full-page and element capture, 12 device presets, custom viewports, retina scale, PDF controls, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user-agent, timezone, geolocation, transparent backgrounds, resizing, chosen-TTL caching, signed links, asynchronous webhooks, bulk capture of 100 URLs per call, usage reporting and an OpenAPI specification. Parameter names used by other screenshot APIs also work. The Free plan includes 1,000 shots each month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Practical decision checklist

  • Choose wkhtmltoimage when your pages are compatible with Qt WebKit and you want a small command-line workflow.
  • Choose P/Invoke only when you can own native ABI, marshaling and lifecycle details.
  • Choose a wrapper after checking its release status and native deployment model.
  • Choose Chromium when modern browser compatibility is more important than the existing wkhtmltoimage dependency.
  • Choose an API when you want to avoid installing browser binaries and need repeatable request controls, verdicts and billing visibility.

Frequently Asked Questions

Does wkhtmltoimage require X11 or a desktop session?

The tool is designed to render without a display service, so a server can run it headlessly; native dependencies still vary by operating-system build.

Can I render a local HTML file?

Yes. Pass the file as the input and configure local-file access or narrowly scoped allow paths when the page references local assets.

Is wkhtmltoimage the same as Chrome?

No. It uses Qt WebKit, while Chrome-based tools use Chromium; differences in CSS and JavaScript support are expected.

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

What should I pin for production?

Pin the executable or package version, operating-system image, architecture and native libraries, then run a regression set of representative pages after upgrades.

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.