Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk8 min

wkhtmltoimage on AWS Lambda: Package and Run Website Screenshot Jobs

A practical guide to packaging wkhtmltoimage for Lambda, configuring native libraries and fonts, choosing a layer or container image, and handling runtime and security limits.

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.

You can run wkhtmltoimage in AWS Lambda by packaging a Linux-compatible binary together with its native libraries and fonts, then invoking it from a handler that writes output under /tmp. The upstream project documents an Amazon Linux 2 Lambda archive suitable for bundling or a layer; a Lambda container image is another option when you need more control over the operating-system dependencies. Neither route removes the need to verify compatibility with your chosen runtime and architecture.

Choose a packaging route

The right package depends on how much dependency control you need and whether the documented legacy archive matches your function environment. The available documentation does not establish a compatibility matrix for every wkhtmltoimage archive, Lambda runtime, and architecture combination, so verify the exact combination you deploy.

As an Amazon Associate I earn from qualifying purchases.

Route When it fits What to check
Amazon Linux 2 Lambda archive as a layer or bundled files The upstream project documents this Lambda-specific archive and its library and font paths. Project downloads and Lambda guidance Runtime and architecture compatibility, layer count and package size, native dependencies, fonts, and how you will update the bundle.
Lambda container image Useful when you want to assemble and control the operating-system libraries and fonts alongside the function. Linux compatibility, runtime interface client if required, image size, local testing, and consistency between build and runtime. AWS image requirements
A different renderer Consider when the target depends on modern browser behavior or dynamic JavaScript. Browser-engine currency, JavaScript fidelity, package size, startup and execution needs, and security. The project maintainer suggests considering Puppeteer for dynamic pages. Project status

What must be in the package

The executable and native libraries

wkhtmltoimage is a command-line HTML-to-image tool based on Qt WebKit; it does not require a display server. Project overview But “static” Qt does not mean every dependency is included: the project notes that system packages remain dependencies and recommends distribution-specific builds. Do not assume that a binary built for an arbitrary Linux distribution or Alpine will work unchanged in Lambda.

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

Fonts and font configuration

Image text depends on available fonts and the fontconfig/freetype setup, not just the executable. The upstream Amazon Linux 2 Lambda example sets LD_LIBRARY_PATH=/opt/lib and FONTCONFIG_PATH=/opt/fonts; its downloads page specifically calls out the fontconfig environment variable when using the archive as a layer. Keep those paths aligned with the actual contents and layout of your package.

#1 Best Overall
Apple 2020 Mac Mini with Apple M1 Chip, 8GB RAM, 256GB SSD Storage - Silver (Renewed)
  • Apple-designed M1 chip for a giant leap in CPU, GPU, and machine learning performance
  • 8-core CPU packs up to 3x faster performance to fly through workflows quicker than ever*
  • 8-core GPU with up to 6x faster graphics for graphics-intensive apps and games*
  • 16-core Neural Engine for advanced machine learning
  • 8GB of unified memory so everything you do is fast and fluid

Package the documented archive as a layer or bundled files

The project’s Lambda archive is the most direct starting point when its Amazon Linux 2 build is compatible with your function. The steps below describe the packaging decisions and invocation pattern; they are not a claim that a particular sample was tested in a live Lambda deployment.

  1. Download the Amazon Linux 2 Lambda archive linked from the upstream downloads page, then inspect its contents rather than assuming directory names.
  2. Choose either a Lambda layer or files bundled with the function. For the documented example, ensure the executable is available to the handler and the archive’s libraries and fonts are under the expected paths.
  3. Configure LD_LIBRARY_PATH as /opt/lib and FONTCONFIG_PATH as /opt/fonts for that archive layout. If your bundle uses different paths, set the corresponding values to those actual locations.
  4. Deploy to a runtime and architecture that can execute the packaged binary and its libraries. Verify by invoking a small known page and checking the resulting file, logs, and Lambda response.

Package with a Lambda container image

A container image gives you control over the Linux libraries, fonts, and renderer installation as a unit. Lambda requires a Linux image compatible with its runtime model. AWS base images include runtime components; an OS-only or alternative base image needs a Lambda runtime interface client. Push the image to Amazon ECR in the same AWS Region as the function. See Lambda container image requirements and AWS Python container-image guidance.

Rank #2
GMKtec Mini PC Computer, G10 Ryzen 5 3500U (Beats N150/4300U/3200U), 16GB RAM 512GB SSD 2.5GbE NIC LAN Desktop Office Home Business HTPC, Triple 4K Display, WiFi, BT, USB-C, DP, Type-C PD, HDMI 2.1
  • MINI PC COMPUTER OFFICE LIGHT GAMING - GMKtec Nucbox G10 Series is equipped with the Ryzen 5 3500U, a 64-bit quad-core mid-range performance x86 mobile microprocessor. This processor is based on AMD's Zen+ microarchitecture and is fabricated on a 12 nm process. The 3500U operates at a base frequency of 2.1 GHz with a TDP of 15 W and a Boost frequency of 3.7 GHz. This APU supports up to 32 GB of dual-channel DDR4-2400 memory and incorporates Radeon Vega 8 Graphics operating at up to 1.2 GHz. 20% Multi-core Performance increase over previous Ryzen 3 models such as 4300U. 35% performance increase over the Intel N-series N95/N97/N150.
  • RYZEN 5 3500U vs RYZEN 3 4300U COMPARISON - Why Choose Ryzen 5 3500U: Better multi-threaded performance: More threads, better suited for multitasking and demanding applications. Better graphics: With Vega 8, it's superior for casual gaming, video playback, and GPU-intensive tasks. Overall higher performance: Higher boost clock and better ability to handle a variety of workloads, from light gaming to productivity tasks. So, if you're looking for a more balanced processor with stronger multitasking capabilities and better GPU performance, the Ryzen 5 3500U would be the clear choice.
  • 16GB DUAL CHANNEL DDR4 + 512GB SSD - Installed with DDR4 16GB SO-DIMM RAM Dual Channel (2x8GB) and a 512GB SSD, the Nucbox G10 mini pc supports memory expansion to 64GB RAM. Featured with Dual M.2 2280 PCIe 3.0 slots, supports dual storage slot expansion to 16TB SSD (2*8TB). (Upgrades not included) This model supports a configurable TDP-down of 12 W and TDP-up of 35 W.
  • UNLEASH RAW PERFORMANCE MODE 25W - Dominate demanding tasks with the AMD Ryzen 5 3500U processor. When switched to Performance Mode in the BIOS (press "Esc" key repeatedly during boot, save then exit), this mini PC delivers superior multi-core processing power, significantly outperforming Intel N-series chips in CPU-intensive applications, multitasking, and creative workloads.
  • MINI DESKTOP COMPUTER WITH TRIPLE DISPLAY SCREEN - Nucbox G10 integrates AMD Radeon Vega 8 1200 MHz GPU to deliver powerful graphics processing power to easily handle video editing, and playback, or casual gaming. And it can connect to 3 display screens simultaneously via HDMI 2.1 TMDS/ DPv1.4/ TYPE-C.
  1. Select a base image compatible with the Lambda runtime and target architecture.
  2. Install or copy a distribution-compatible wkhtmltoimage build, its required system libraries, fontconfig, freetype, and the fonts your pages need.
  3. Configure library and font paths as necessary, and make the handler invoke the executable by a known path.
  4. Ensure the image follows Lambda’s filesystem and runtime requirements. In AWS’s words, “The container image must be able to run on a read-only file system.”
  5. Build for the chosen architecture, upload the image to ECR in the function’s Region, and use the Lambda runtime interface emulator for local container testing as described in AWS’s guidance.

Lambda container images can be up to 10 GB uncompressed. That ceiling is not a target: large browser-related dependencies can affect image distribution and update workflows, so keep only the libraries and fonts you need.

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

Invoke the renderer from a Lambda handler

The handler should construct the command without shell interpolation, save the image in /tmp, and return either a small response or a reference to an object stored elsewhere. This Python example shows the invocation pattern; it assumes your executable, libraries, and fonts are already packaged and configured.

Rank #3
Apple Late 2018 Mac Mini with 3.0GHz Intel Core i5 (8GB RAM, 256GB SSD) Space Gray (Renewed)
  • 6-core Intel Core i5 processor
  • Intel UHD Graphics 630
  • 8GB 2666MHz DDR4
  • Ultrafast SSD storage
  • Four Thunderbolt 3 (USB-C) ports, one HDMI 2. 0 port, and two USB 3 ports
import os
import subprocess
import uuid

WKHTMLTOIMAGE = "/opt/bin/wkhtmltoimage"  # Change to the packaged executable path.


def lambda_handler(event, context):
    url = event.get("url")
    if not isinstance(url, str) or not url.startswith(("https://", "http://")):
        return {"statusCode": 400, "body": "Provide an http or https URL."}

    output_path = f"/tmp/{uuid.uuid4().hex}.png"
    env = os.environ.copy()
    env["LD_LIBRARY_PATH"] = "/opt/lib:" + env.get("LD_LIBRARY_PATH", "")
    env["FONTCONFIG_PATH"] = "/opt/fonts"

    result = subprocess.run(
        [WKHTMLTOIMAGE, "--format", "png", url, output_path],
        capture_output=True,
        text=True,
        timeout=840,
        env=env,
        check=False,
    )
    if result.returncode != 0:
        return {"statusCode": 502, "body": result.stderr[-4000:]}

    with open(output_path, "rb") as image_file:
        image_bytes = image_file.read()

    # Return only small images inline. For larger output, upload to object storage
    # and return a URL or object key instead of placing the bytes in this response.
    return {
        "statusCode": 200,
        "headers": {"Content-Type": "image/png"},
        "isBase64Encoded": True,
        "body": __import__("base64").b64encode(image_bytes).decode("ascii"),
    }

For a production job, validate URLs beyond checking their scheme, set an explicit renderer timeout below the Lambda timeout, and decide how to handle nonzero exits, partial files, and oversized images. An invocation may leave files in /tmp for reuse by a warm execution environment; use unique names and remove temporary files when they are no longer needed.

Lambda limits that shape screenshot jobs

AWS’s current Lambda quotas specify a standard invocation timeout of 900 seconds, memory from 128 MB to 10,240 MB, and configurable /tmp storage from 512 MB to 10,240 MB. Synchronous request and response payloads are each limited to 6 MB. See AWS Lambda quotas.

Rank #4
Sale
Apple 2024 Mac mini Desktop Computer with M4 chip with 10‑core CPU and 10‑core GPU: Built for Apple Intelligence, 16GB Unified Memory, 512GB SSD Storage, Gigabit Ethernet. Works with iPhone/iPad
  • SIZE DOWN. POWER UP — The far mightier, way tinier Mac mini desktop computer is five by five inches of pure power. Built for Apple Intelligence.* Redesigned around Apple silicon to unleash the full speed and capabilities of the spectacular M4 chip. With ports at your convenience, on the front and back.
  • LOOKS SMALL. LIVES LARGE — At just five by five inches, Mac mini is designed to fit perfectly next to a monitor and is easy to place just about anywhere.
  • CONVENIENT CONNECTIONS — Get connected with Thunderbolt, HDMI, and Gigabit Ethernet ports on the back and, for the first time, front-facing USB-C ports and a headphone jack.
  • SUPERCHARGED BY M4 — The powerful M4 chip delivers spectacular performance so everything feels snappy and fluid.
  • BUILT FOR APPLE INTELLIGENCE — Apple Intelligence is the personal intelligence system that helps you write, express yourself, and get things done effortlessly. With groundbreaking privacy protections, it gives you peace of mind that no one else can access your data — not even Apple.*
  • Write the generated file and other temporary artifacts under /tmp; do not rely on writing to the container’s read-only filesystem.
  • Set memory, temporary storage, and timeout based on the page and output your workload needs, then observe actual invocations. No general rendering speed or memory figure is established here.
  • Keep synchronous responses within the payload limits. For larger images or PDFs, use external object storage and return an object key or link rather than assuming the Lambda response can carry the file.
  • Handle slow or unreachable pages before Lambda’s overall timeout expires. A renderer timeout shorter than the function timeout leaves time to return an error or clean up.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Security and rendering limits

The project’s stable series is 0.12.6, released June 11, 2020. Its status page says Qt 4 had been unsupported since 2015 and the WebKit component had not been updated since 2012. These are the maintainer’s published project-status statements, not a fresh security audit; they are important signals to evaluate before using this renderer for current public pages or sensitive workloads. Downloads · Status

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

The maintainer warns that rendering untrusted HTML or JavaScript can lead to complete server takeover and recommends sanitization and mandatory access control such as AppArmor or SELinux. A URL screenshot worker should also validate inputs and limit the renderer’s network reach—for example, prevent requests to internal services and metadata endpoints. These are application and infrastructure safeguards; wkhtmltoimage does not itself enforce them.

Best Value
Sale
Apple 2026 Mac mini Desktop Computer M6 chip
  • LITTLE DO-IT-ALL — Mac mini packs pure power into a small, five-by-five-inch desktop as the M6 chip delivers next-level AI capabilities. Mac mini features 2.5Gb Ethernet with support for Wi-Fi 7* and Bluetooth 6, with ports on the front and back.
  • M6 CHIP — Everything you do on Mac mini feels more responsive with the M6 chip and its next-generation CPU. Fly through AI workflows with up to 4.8x faster AI performance,* thanks to a Neural Accelerator in each GPU core, faster unified memory, and a Dual 16-core Neural Engine.
  • CONNECT IT ALL — Features three Thunderbolt 4 ports, an HDMI port, and a 2.5Gb Ethernet port in the back, and two USB-C ports and a headphone jack in front. Supports up to three external displays. With the Apple-designed N1 wireless chip for Wi-Fi 7* and Bluetooth 6.
  • A POWERFUL PLATFORM FOR AI — Apple silicon is designed to run demanding AI workflows like using huge LLMs, directly on device. And Apple Intelligence* helps you write, express yourself, and get things done effortlessly, while Siri AI* is your profoundly capable assistant — all with groundbreaking privacy protections.
  • A POWERFUL PLATFORM FOR AI — Apple silicon is designed to run demanding AI workflows like using huge LLMs, directly on device.

Troubleshooting common failures

  • Executable not found or permission denied: Confirm the packaged path, file permissions, and that the handler invokes the same path. In a layer, inspect the mounted directory structure rather than assuming it matches the example.
  • “Error while loading shared libraries”: The binary’s system dependencies are missing or the loader cannot find them. Include compatible libraries and set LD_LIBRARY_PATH to their actual directory; do not treat static Qt linking as proof that all dependencies are bundled.
  • Text is missing, substituted, or has boxes: Package the needed fonts and the fontconfig/freetype dependencies; set FONTCONFIG_PATH to the actual font configuration directory. Test with a page containing the scripts and glyphs your workload requires.
  • Blank or incomplete image: The page may rely on JavaScript unsupported by the older WebKit engine, load slowly, or block the renderer. Check stderr and page behavior; for modern dynamic pages, consider a maintained browser automation approach rather than assuming a longer wait will fix engine incompatibility.
  • Works locally but fails in Lambda: Compare OS distribution, architecture, library versions, environment paths, filesystem permissions, and available fonts. For containers, use the Lambda runtime interface emulator as a local validation aid, while still verifying in the deployed runtime.
  • Timeout or storage exhaustion: Reduce unnecessary page work, choose suitable memory and /tmp limits, impose a renderer timeout, and avoid accumulating files in /tmp. The function timeout cannot exceed 900 seconds.
  • Unexpected access to internal URLs: Restrict accepted destinations and outbound network access. A screenshot endpoint that accepts arbitrary URLs can otherwise become a path to resources the caller should not reach.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server: call one endpoint with a URL and receive an image or PDF. For example, this cURL request saves a WebP screenshot of Stripe:

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 setup and options. Cookie banners are accepted and removed along with 60+ known consent platforms, newsletter popups, and chat widgets before capture; these steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers identifying the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Does wkhtmltoimage need X11 or a display server in Lambda?

No. It is a headless command-line renderer, so a display server is not required.

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

Can I use the Amazon Linux 2 archive with any Lambda runtime?

Compatibility with every runtime and architecture is not established. Confirm the archive, libraries, and target function environment match before deployment.

What should I use for pages that depend on modern JavaScript?

The project maintainer recommends considering Puppeteer or wrappers for dynamic pages; choose based on your rendering fidelity, deployment, and security requirements.

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.

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

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.