How to Install wkhtmltoimage on Ubuntu in Hindi
Install Ubuntu’s wkhtmltoimage command through the wkhtmltopdf package, verify it, and troubleshoot common issues with this English-language guide.
Direct answer: On Ubuntu, install the wkhtmltoimage command by installing the wkhtmltopdf package, then check the command with wkhtmltoimage --version. The commands below are in English; this guide explains the steps and options in English.
sudo apt update
sudo apt install wkhtmltopdf
wkhtmltoimage --version
Ubuntu’s Jammy manpage identifies wkhtmltopdf as the package providing wkhtmltoimage. Package versions can vary by Ubuntu release. Ubuntu Jammy wkhtmltoimage manpage
1. What wkhtmltoimage does
wkhtmltoimage converts an HTML page into an image from the command line. Its basic syntax is:
wkhtmltoimage [OPTIONS]... <input file or URL> <output file>
The wkhtmltopdf project describes its command-line renderers as using Qt WebKit and running headlessly, without a display or display service. Official project repository
2. Install the Ubuntu package
- Refresh the package index so APT has current package metadata:
sudo apt update
- Install the package that provides the command:
sudo apt install wkhtmltopdf
Review APT’s proposed package and dependency changes, then confirm the installation if prompted. You do not need to install a graphical desktop solely to invoke the renderer: the project documents headless operation.
- Verify that the executable is available and inspect its version:
wkhtmltoimage --version
command -v wkhtmltoimage
Ubuntu’s Jammy package record documents version 0.12.6-2. Ubuntu Noble’s package record lists 0.12.6-2build2. The project’s download page calls 0.12.6 its stable series and dates it to June 11, 2020. These identifiers are release-specific; they do not establish which version is available for every Ubuntu release or CPU architecture. Ubuntu Noble package record · Official project downloads
3. Convert a local HTML file or web page
Local HTML file
From the directory containing the input file, run:
wkhtmltoimage input.html output.png
For example, replace input.html with the path to your own file. The command’s final argument is the destination image path.
Web page URL
wkhtmltoimage https://example.com page.png
This shows the documented input/output form using a URL. It is syntax guidance, not a claim that a particular page was captured or tested.
Choosing the output format
Use an output filename with the image extension you want, such as .png, .jpg, or .webp, subject to the capabilities of the installed build. If conversion fails for a requested format, check the installed version’s help output and use a supported format:
wkhtmltoimage --help
4. Useful options and configuration
Available flags and behavior can depend on the installed build. Treat wkhtmltoimage --help as the local reference for exact option names and defaults. Common needs to check in that help include:
- Dimensions: set the viewport width and height when page layout depends on the browser window.
- Full-page output: configure the output height or relevant smart-width behavior if the result should include more than the initial viewport.
- JavaScript timing: adjust the delay or JavaScript-related settings for pages that populate content after initial load.
- Images and loading: verify that remote resources are reachable and that the renderer waits long enough for them.
- Headers, cookies, and authentication: consult the installed help if the target page requires a session or request metadata.
Do not assume modern browser behavior: this project uses Qt WebKit, so pages that depend on newer browser APIs or CSS may render differently. The source dossier does not establish the exact option set for every Ubuntu package build; consult that build’s help rather than copying flags from a different release.
5. Ubuntu release and package-source considerations
Start with Ubuntu’s repository package for the Ubuntu release installed on the machine. The documented Jammy and Noble package records show that package versions vary. The official project also publishes release packages and lists Ubuntu targets, including 22.04, but the project release build and Ubuntu repository package should not be assumed to be identical.
If considering a project-provided package instead, check that its listed Ubuntu release and architecture match the host, compare its version and dependencies with the repository package, and use the project’s official download page. The available sources do not establish support for every Ubuntu release or architecture.
6. Troubleshooting
| Symptom | Likely cause | What to do |
|---|---|---|
wkhtmltoimage: command not found |
The package is not installed, or the executable is not on the current shell’s PATH. | Run sudo apt update and sudo apt install wkhtmltopdf, then check command -v wkhtmltoimage. If APT says it is installed but the command is missing, inspect the package contents and PATH for that system. |
APT cannot locate wkhtmltopdf |
Package indexes may be stale, or the configured repositories do not provide the package for that release. | Run sudo apt update, inspect APT’s repository configuration and the Ubuntu package record for the release, and confirm the system’s release and architecture before choosing another package source. |
| The command runs but the output is blank or incomplete | The page may need JavaScript or additional time to load; a remote resource may also be inaccessible. | Check the command’s help for load timing and JavaScript options. Confirm the input URL is reachable from the host and inspect whether the page requires login or blocks automated requests. |
| The output layout differs from a current browser | The renderer uses Qt WebKit and may not support newer browser features the page uses. | Try a simpler page or compatible markup, and verify the result against the renderer’s supported behavior. For pages requiring a current browser engine, use a capture method built for that requirement. |
| A requested output format is rejected | The installed build may not support that format or the output filename may be invalid. | Review wkhtmltoimage --help and try a supported extension such as PNG or JPEG. |
7. Security, performance, and reliability
Do not render untrusted HTML unsafely
The project warns: “Do not use wkhtmltopdf with any untrusted HTML – be sure to sanitize any user-supplied HTML/JS, otherwise it can lead to complete takeover of the server on which it is running!” Attribute that warning to the wkhtmltopdf project. If a server renders user-submitted content, treat sanitization and isolation as essential security controls; do not feed arbitrary HTML or JavaScript to a privileged server process.
Plan for rendering time and failures
Capture time depends on the page, its scripts, resource availability, and the host. A page that waits on remote assets or keeps network activity open can take longer or produce incomplete output. For repeatable jobs, set an appropriate timeout in the calling process, record the input and exit status, and retain stderr so failures can be diagnosed. The research sources provide no benchmark or fixed performance figure.
Keep costs and dependencies predictable
The Ubuntu package route uses APT and pulls in the dependencies required by that release’s package. Review APT’s plan before confirming, especially on a minimal server. No license price or hosting cost is asserted here; resource use and operating cost depend on the machine and workload.
8. Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. It can help when you want an image without installing and maintaining a browser-rendering package on your own machine.
Its capture flow accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers indicate the page verdict and billing status. AI agents can use its MCP server tools take_screenshot, get_page_info, and capture_pdf.
See the ScreenshotNeo API documentation for options and setup. Example cURL request:
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}`);
ScreenshotNeo includes 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account to get started.
9. Frequently asked questions
Why is the package called wkhtmltopdf if I need wkhtmltoimage?
Ubuntu’s Jammy manpage identifies wkhtmltopdf as the package providing the wkhtmltoimage command.
Does wkhtmltoimage need a graphical desktop?
The project describes its command-line tools as headless and says they run without a display or display service.
Is version 0.12.6 available on every Ubuntu system?
The cited Ubuntu records document specific releases and versions, while the project page lists particular release targets. Check the package metadata for your own Ubuntu release and architecture.
Can I safely use it to render HTML submitted by website visitors?
Only with appropriate sanitization and security isolation. The project explicitly warns that untrusted HTML or JavaScript can put the rendering server at risk.


