Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Use Playwright to render HTML in a browser, then capture the rendered page as WebP with page.screenshot({ type: 'webp' }). For an HTML string, load it with page.setContent(); choose whether to capture only the viewport or the full page, and save the result to a file or use the returned buffer.
Convert an HTML string to a WebP file
Install Playwright in your TypeScript project and use its Chromium browser to render the markup. This complete example writes a full-page WebP screenshot to out.webp:
import { chromium } from 'playwright';
async function main(): Promise<void> {
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.setContent(`
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
body { font-family: sans-serif; padding: 2rem; }
h1 { color: #2864dc; }
</style>
</head>
<body>
<main><h1>Hello, WebP</h1><p>Rendered from HTML.</p></main>
</body>
</html>
`);
await page.screenshot({
path: 'out.webp',
type: 'webp',
fullPage: true,
});
} finally {
await browser.close();
}
}
main().catch((error: unknown) => {
console.error(error);
process.exitCode = 1;
});
page.setContent() puts the HTML into a browser page; page.screenshot() captures the browser-rendered pixels. This is not a direct conversion of HTML source into image bytes. The documented API waits for the page’s load event by default when setting content. If the markup relies on external stylesheets, fonts, images, or scripts, make sure they have loaded and reached the intended visual state before capturing. See the Playwright Page API for the current API details; pin and check the Playwright version used by your project because the documentation cited here does not specify an installed package version.
Choose the capture settings
These options determine what appears in the image and how its pixels are represented:
#1 Best Overall
- AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
- FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
- FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
- UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
- A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.
| Choice | Setting | Effect |
|---|---|---|
| Visible area or whole document | fullPage: false or omit it; set fullPage: true for the full page |
The default capture is the visible viewport. Full-page capture extends through the scrollable page. |
| CSS pixels or device pixels | scale: 'css' or scale: 'device' |
css produces one image pixel per CSS pixel. device, the documented default, captures device pixels and can create a larger image on a high-density display. |
| Lossless or lossy WebP | quality: 100 or a lower value from 0 to 100 |
The documented default is 100, which produces lossless WebP. Lower quality uses lossy compression; compare the result for your page if file size matters. |
| Opaque or transparent background | omitBackground: true for transparency |
Omits the default white background. This option does not apply to JPEG. |
Playwright supports PNG and JPEG as well as WebP; PNG is the default if you do not select another format. Specify both type: 'webp' and a .webp filename to make the intended format explicit. For example:
await page.screenshot({
path: 'out.webp',
type: 'webp',
fullPage: true,
quality: 85,
scale: 'css',
});
Here, quality 85 requests lossy WebP, and CSS scaling keeps one image pixel per CSS pixel. Omit path when you want the screenshot bytes in memory instead of a file:
const webpBuffer = await page.screenshot({ type: 'webp', fullPage: true });
The returned value is a Node.js Buffer, which you can pass to your storage or response-handling code.
Capture an existing web page instead
For a URL rather than an HTML string, navigate before taking the screenshot. This example uses the same explicit file and format settings:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesRank #2
- BUILT FOR COLLEGE. AND BEYOND — MacBook Air with the M5 chip packs blazing speed and powerful AI capabilities into an incredibly portable design. And with up to 18 hours of battery life,* this thin and light powerhouse is ready to take on almost any major, just about anywhere.
- TEAR THROUGH TOUGH ASSIGNMENTS — With its faster CPU and unified memory, the M5 chip delivers even more performance and fluidity across apps, making multitasking and creative workflows smooth and responsive. A powerful Neural Engine and next-generation GPU with Neural Accelerators give you a powerful platform for AI.
- MAKE QUICK WORK OF YOUR TO-DO LIST — Apple Intelligence helps you write, express yourself, and get things done effortlessly — whether it’s for school or everyday life. With groundbreaking privacy protections, it gives you peace of mind that no one else can access your data — not even Apple.*
- UP TO 18 HOURS OF BATTERY LIFE — MacBook Air delivers incredible battery life with amazing performance, so you can power through a full day of classes without worrying about plugging in.
- A BRILLIANT 13.6-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Air supports 1 billion colors, making photos and videos pop with rich contrast and sharp detail, and text appears supercrisp. So everything — from class presentations to movies to games — looks truly stunning.
import { chromium } from 'playwright';
async function main(): Promise<void> {
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'page.webp', type: 'webp', fullPage: true });
} finally {
await browser.close();
}
}
main().catch((error: unknown) => {
console.error(error);
process.exitCode = 1;
});
For dynamic sites, do not assume that navigation alone means every visual dependency is ready. Wait for the page state your capture needs—for example, a particular element to appear—before taking the screenshot. Playwright documents wait conditions for page operations, and cautions against using networkidle for testing; select a condition appropriate to the page rather than relying on a generic delay.
Control visual consistency
A WebP screenshot is a raster image of a browser rendering, not a semantic copy of the HTML. Viewport dimensions, CSS, available fonts, resource loading, animation state, browser version, operating system, hardware, settings, and headless mode can affect the pixels.
- Set the viewport deliberately when output dimensions matter.
- Use
scale: 'css'when you want one output pixel per CSS pixel; use device scaling when device-pixel capture is intended. - Wait for required fonts, images, and scripts and put animations or other changing content into a stable state before capture.
- For visual regression work, keep the browser and host environment consistent. Playwright Test’s
toHaveScreenshot()waits for two consecutive screenshots to match before comparing; a.webpsnapshot filename selects WebP output. This is a Playwright Test runner assertion, not a requirement for a one-off screenshot.
See the Playwright visual comparisons documentation for screenshot assertion behavior.
Troubleshooting common problems
The output is PNG instead of WebP
PNG is the default screenshot format. Set type: 'webp', and use a filename ending in .webp. A filename extension alone may be used to infer the format, but specifying both makes the intent unambiguous.
Rank #3
- FULL HD IPS DISPLAY - Enjoy vibrant, crystal-clear images with 178-degree wide-viewing angles
- AMD RYZEN 3 30 PROCESSOR - Everyday performance you can count on; Multitask, stream, game casually, and edit photos smoothly with responsive power and vibrant HDR visuals
- ENJOY UP TO 14 HOURS AND 15 MINUTES OF BATTERY LIFE - HP Fast Charge restores battery from 0 to 50% in approximately 45 minutes
- AMD RADEON 610M GRAPHICS - Experience smooth entertainment; Built for streaming and multitasking, enjoy realistic visuals and efficient performance for work and play
- STORAGE AND MEMORY - 512 GB PCIe NVMe M.2 SSD offers fast speed and efficient storage; and 8 GB LPDDR5 RAM memory boosts performance with higher bandwidth
The screenshot cuts off content
Without fullPage: true, Playwright captures the visible viewport. Enable that option to include the scrollable page, and verify the page has finished rendering content that appears lower down.
Images, fonts, or styles are missing
Check that external resources are reachable and allowed to load, and wait until the required content is ready before capturing. setContent() defaults to the load event; pages with later-loading resources may need a more specific readiness condition.
The output is unexpectedly large or looks different
Device-pixel scale can produce more pixels than CSS-pixel scale on a high-density display. For a smaller image, compare scale: 'css' and an appropriately lower WebP quality; lower quality is lossy, so inspect the result rather than assuming it preserves every detail. Use quality 100 when lossless output is needed.
The output has a white background
Set omitBackground: true if you need transparency. It does not apply to JPEG; use WebP or another supported format that meets your transparency needs.
Rank #4
- Effortlessly chic. Always efficient. Finish your to-do list in no time with the Dell 15, built for everyday computing with Intel Core 3 processor.
- Designed for easy learning: Energy-efficient batteries and Express Charge support extend your focus and productivity.
- Stay connected to what you love: Spend more screen time on the things you enjoy with Dell ComfortView software that helps reduce harmful blue light emissions to keep your eyes comfortable over extended viewing times.
- Type with ease: Write and calculate quickly with roomy keypads, separate numeric keypad and calculator hotkey.
- Ergonomic support: Keep your wrists comfortable with lifted hinges that provide an ergonomic typing angle.
Or skip the browser setup
For a URL-based screenshot, ScreenshotNeo provides a one-request API that returns WebP, PNG, JPEG, or PDF. It can accept cookie banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides screenshot tools for AI agents and MCP clients.
Use an API key in place of YOUR_API_KEY; the API documentation is at ScreenshotNeo docs.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Free includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots. Learn more at ScreenshotNeo, or sign up free.
Frequently Asked Questions
Can Playwright return WebP screenshot data without writing a file?
Yes. Omit the path option from page.screenshot(); it returns a Node.js Buffer.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Does converting HTML to WebP preserve the HTML structure?
No. Playwright renders the page and captures its appearance as a raster image; the screenshot does not retain semantic HTML.
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.




