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

Set the rendering viewport with --width and --height, then use --disable-smart-width when the width must be strict. To crop the resulting image to exact pixel bounds, add --crop-x, --crop-y, --crop-w, and --crop-h.

wkhtmltoimage --width 1200 --height 800 --disable-smart-width input.html output.png

That command renders the page in a 1200×800 viewport. It does not, by itself, guarantee that the HTML has no overflow or that every visible pixel belongs to a 1200×800 content region; viewport sizing and output cropping are separate controls.

What each dimension controls

wkhtmltoimage converts an HTML page into an image. Its dimensions are controlled at two different stages:

  • Viewport dimensions: --width sets the screen width used for layout, and --height sets screen height.
  • Crop dimensions: --crop-w and --crop-h choose the width and height of the output region; --crop-x and --crop-y move that region away from the top-left corner.

Keeping these concepts separate explains most “wrong size” results. A viewport changes how CSS media queries, wrapping, and responsive components behave. A crop selects pixels after rendering. Cropping cannot repair a layout that was rendered at the wrong viewport.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

Width is normally a guideline

The documented behavior of --width is intentionally flexible: it is used as a guideline unless smart-width behavior is disabled. With smart width enabled, wkhtmltoimage can expand the effective width to accommodate unbreakable content. A long unbroken URL, fixed-width table, or oversized element can therefore make the image wider than the number you supplied.

Height can be fixed or content-derived

When you pass --height, the renderer uses that screen height. If you omit it, wkhtmltoimage calculates the vertical extent from page content. Omitting height is useful for a full-page image; specifying it is better for a predictable viewport such as a social-card template or a test fixture.

Set a fixed viewport from the command line

  1. Confirm the installed build and version:
    wkhtmltoimage --version
  2. Place the viewport options before the input and output paths.
  3. Use --disable-smart-width if the requested width must remain fixed.
  4. Open the generated file and inspect both its pixel dimensions and the page layout for overflow.

Fixed width and height

wkhtmltoimage --width 1200 --height 800 input.html output.png

This asks for a 1200-pixel screen width and an 800-pixel screen height. It is appropriate when you want the page to behave as though it were displayed in a fixed browser window.

Strict width for reproducible output

wkhtmltoimage --width 1200 --height 800 --disable-smart-width input.html output.png

Use this form for screenshot tests, fixed design exports, and pipelines in which a widening layout would break downstream processing. Strict width fixes the rendering window; it does not eliminate CSS overflow. An element wider than its container may still be clipped or extend beyond the intended design.

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

Full-page capture with a controlled width

wkhtmltoimage --width 1200 --disable-smart-width input.html full-page.png

Because no height is supplied, the vertical extent follows the page content. If JavaScript adds content after the initial load, allow the page time to finish before capture:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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 --width 1200 --disable-smart-width --javascript-delay 1500 input.html full-page.png

The delay is expressed in milliseconds. Choose it from the behavior of your page; a delay that is too short captures incomplete content, while an unnecessarily long delay slows every conversion. For pages whose readiness can be detected more reliably in your surrounding application, wait for that condition before invoking wkhtmltoimage rather than relying on a large fixed delay.

Crop the output to exact pixel bounds

Use crop options when the final file must have exact bounds, regardless of how large the rendered page is:

wkhtmltoimage --width 1200 --height 800 --disable-smart-width --crop-w 1200 --crop-h 800 input.html cropped.png

In this example, the viewport and crop are both 1200×800, so the output is an exact 1200×800 image provided the renderer completes successfully.

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

Crop a region below or to the right

wkhtmltoimage --width 1600 --height 1200 --disable-smart-width 
  --crop-x 200 --crop-y 100 --crop-w 1200 --crop-h 800 
  input.html region.png

--crop-x 200 and --crop-y 100 set the crop region’s top-left coordinate in rendered pixels. The crop then extends 1,200 pixels wide and 800 pixels high. Ensure the selected rectangle exists in the rendered page; otherwise the result can contain clipped or empty areas.

Viewport versus crop: choose the right control

Goal Use Why
Make responsive CSS render at a desktop width --width Changes the screen width used for layout.
Keep the layout window from expanding --disable-smart-width Turns off smart-width expansion.
Force a predictable screen height --height Sets the rendering window’s height.
Capture the entire page vertically Omit --height Height is calculated from page content.
Guarantee final pixel bounds --crop-w and --crop-h Selects the output rectangle independently of layout.
Start the rectangle away from the origin --crop-x and --crop-y Offsets the crop region from the top-left.

Prevent common causes of unexpected dimensions

Unbreakable content

Long strings, fixed-width tables, preformatted code, and images with explicit widths can exceed the viewport. Decide whether the content should wrap, shrink, or be clipped. CSS such as overflow-wrap: anywhere, a responsive table strategy, or an explicit max-width: 100% on images can prevent expansion, but these are HTML/CSS decisions rather than wkhtmltoimage flags.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

CSS pixels and output pixels

The width and height options describe the renderer’s screen dimensions. Device-pixel scaling, CSS transforms, and image-resampling steps in a later pipeline can change the number of pixels in a file. Measure the final file after conversion when an external system requires an exact size.

JavaScript and late-loading assets

A page can have the correct viewport but still produce an unexpectedly short image if scripts have not inserted their content. Conversely, content that arrives late can make a full-page image taller than an earlier capture. Use --javascript-delay where appropriate and make sure fonts, images, and other resources are reachable from the conversion environment.

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.

Local files and resource access

Relative URLs resolve differently depending on the input location and execution environment. Use stable absolute URLs or a correctly based local document, and verify that the converter can read local assets and contact remote ones. A missing stylesheet can change wrapping and therefore the apparent dimensions of the page.

Useful command patterns

Exact card size

wkhtmltoimage --width 1200 --height 630 --disable-smart-width 
  --crop-w 1200 --crop-h 630 card.html card.png

This is suitable for a fixed social-card canvas when the document itself is designed for that viewport.

Full page, then bounded export

First render at the width needed by your CSS and omit height to obtain the complete page. If a later workflow needs a fixed rectangle, use the crop flags in a second conversion or crop with an image-processing tool that understands the required coordinates. Do not assume a full-page height is interchangeable with a fixed viewport height.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

JPEG output

wkhtmltoimage --width 1200 --height 800 --disable-smart-width input.html output.jpg

The output extension selects a commonly supported format. The underlying image settings also expose formats including JPG, PNG, BMP, and SVG, plus JPEG quality and transparency controls where supported by the build.

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

Library configuration with libwkhtmltox

When embedding the renderer instead of invoking the executable, use the image settings that correspond to the command-line flags:

Library setting Purpose
screenWidth Sets the viewport width.
smartWidth Enables or disables width expansion; set it according to whether a strict width is required.
crop.left / crop.top Equivalent crop offsets.
crop.width / crop.height Equivalent crop bounds.
Output and quality settings Choose format, JPEG quality, and transparency options exposed by the image API.

Set screenWidth first, choose smartWidth, and then apply crop fields when the integration needs a bounded image. The exact wrapper syntax varies by language, so verify that your binding passes integer values and the expected setting names to libwkhtmltox.

Troubleshooting dimensions and rendering

The image is wider than requested

  • Add --disable-smart-width.
  • Inspect for fixed-width elements, long unbroken strings, or oversized images.
  • Check the actual file dimensions and distinguish a wide viewport from content that visually overflows it.

The image is shorter or taller than expected

  • Pass --height for a fixed screen height.
  • For a full-page capture, omit height and check whether late JavaScript changes the content height.
  • Use crop height when the final file must be exactly bounded, independent of page length.

The crop is offset or clips the wrong area

  • Remember that crop coordinates start at the rendered top-left corner.
  • Check --crop-x and --crop-y for accidental offsets.
  • Ensure the crop rectangle fits inside the rendered region and that its width and height match the desired output.

The command fails or behaves differently on another machine

Run wkhtmltoimage --version on both systems. The Debian bookworm manpage identifies package version 0.12.6-2+b1; Debian source documentation references 0.12.6-2, and Ubuntu Jammy documents 0.12.6-2. Other builds, patches, and packaging choices can differ, so record the executable version alongside reproducible screenshots.

The output is blank or missing page content

  • Check that the input path is correct and that the process can access referenced files.
  • Verify network access, certificates, authentication, and redirects for remote assets.
  • Increase the JavaScript wait only after confirming that the page actually needs it.
  • Test the URL in a normal browser and inspect whether a consent dialog, bot check, or login gate prevents the content from appearing.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need an automated screenshot rather than a local wkhtmltoimage pipeline, ScreenshotNeo provides a GET-based website screenshot API. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; 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.

For a one-call capture, create an API key and run:

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 the complete parameter list. Python and Node.js versions are:

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo includes viewport and output controls for full-page captures, CSS-element selection, dark mode, device presets, custom viewports, retina scale, PDF paper and margin settings, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector or network-idle waits, request and resource blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification. Existing parameter names used by other screenshot APIs also work for easier migration.

An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients, so an AI agent can perform the capture without you building browser orchestration. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan, and yearly billing provides two months free.

Start with 1,000 free ScreenshotNeo shots per month—no card required.

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.

Choosing the right approach

  • Use wkhtmltoimage when you control the HTML, need a local command, or are integrating an existing libwkhtmltox application.
  • Use strict width when layout reproducibility matters and your CSS can handle overflow deliberately.
  • Use crop flags when the file’s final pixel rectangle matters more than the page’s natural size.
  • Use a hosted API when consent UI, popups, bot checks, asynchronous jobs, bulk URLs, or AI-agent access would otherwise require substantial browser plumbing.

Frequently Asked Questions

Does --height crop a page to that height?

No. It sets the screen height used for rendering. Use --crop-h when you need the saved image itself to have an exact height.

Can strict width stop horizontal scrolling inside the HTML?

No. --disable-smart-width keeps the rendering window from expanding, but CSS overflow can still occur inside or beyond that window.

Which version should I install?

Reproduce the documented behavior with the version available for your platform, then record wkhtmltoimage --version; package builds and patches can differ.

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.

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