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 DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk6 min

Convert an HTML Page to AVIF with a Headless Browser

Capture a rendered page with headless Chrome or Playwright, then use Sharp to encode the screenshot as AVIF. Choose viewport, element or full-page capture and tune the encoder settings.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Render the page in a headless browser, capture it as PNG or another supported screenshot format, then encode those image bytes as AVIF. The cited Chrome headless CLI writes PNG, and Playwright documents PNG, JPEG and WebP screenshots—not direct AVIF screenshots—so the reliable documented workflow is capture first, convert second.

How the HTML-to-AVIF workflow works

A browser screenshot records the page as rendered, including styling and JavaScript-driven page state. The browser handles HTML rendering; an image encoder handles AVIF output. The steps are:

As an Amazon Associate I earn from qualifying purchases.

  1. Load the URL or HTML document in a headless browser.
  2. Choose the page region and pixel scale to capture.
  3. Capture screenshot bytes or an intermediate image file.
  4. Pass the image to an AVIF encoder and write the result.

Chrome’s Headless command-line reference documents screenshot capture and says the --screenshot flag saves screenshot.png in the current working directory. Playwright’s screenshot guide and Page API document screenshot capture as well. Sharp provides the encoding step through its output API.

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

Can Playwright save a screenshot as AVIF?

The cited Playwright Page API lists png, jpeg and webp as screenshot types; it does not document AVIF as a direct screenshot type. Capture to a buffer in a supported format, then pass that buffer to Sharp’s AVIF encoder. This distinction applies to the cited interfaces; check the documentation for the exact versions installed in your project.

#1 Best Overall
Sale
EMEET S600 4K Webcam for Streaming, Sony 1/2.55'' Sensor, PDAF Autofocus
  • Unmatched 4K Streaming Quality - The EMEET S600 streaming camera boasts a high-definition 4K sony 1/2.55'' sensor, delivering crisp, clear images far exceeding typical webcam quality. With versatile resolution options, enjoy stunning 4K at 30FPS or smooth 1080P at 60FPS. Ideal for aspiring streamers, game streaming, and content creation, this 4K webcam ensures exceptional experience for you and your audience. Note: Video resolution depends on built-in camera software or apps like PotPlayer/OBS.
  • Advanced PDAF Autofocus & Light Balance – 4K webcam S600's PDAF(Phase Detection Autofocus) tech offers significant advantages over common autofocus such as faster speed, higher precision, and more stable performance in various scenes features. Its auto light adjustment capability balances shadows and highlights even in low-light environments, keeping every detail sharp and clear on screen, making it ideal for content creators and live streamers who demand top-tier performance and visual quality.
  • Enhanced Audio Clarity & Customizable FOV - The EMEET S600 4K streaming webcam is equipped with premium microphones that use a proprietary algorithm to filter out background noise and capture your voice with exceptional clarity. Noise-canceling feature is enabled by default but can be turned off through the EMEETLINK software. At 1080P, the FOV adjusts 40°-73°, allowing you to focus on you and surroundings, while at 4K, it’s fixed at 73° for better image quality and less distortion.
  • Integrated Privacy Cover & Rugged Design - The 4K webcam for streaming boasts a built-in privacy cover right on the lens, ensuring it won't accidentally open or get touched. Crafted with meticulous engineering, every component of the S600, from the clips to the joints, is designed for durability and stability. Unlike traditional 4K streaming cameras, S600 webcam for PC offers flexible rotation and wide-angle tilting while staying securely in place, making it easier to find your ideal angle.
  • Effortless Setup with Customization Option - S600 2.0&3.0 USB webcam offers a seamless plug-and-play experience, compatible with nearly all popular operating systems and software, no extra software required for use. Just plug it in, and you’re ready to go, making it an easy addition to your workflow. For those looking to fine-tune image parameters or enhance sound quality, EMEETLINK software is available for advanced customization. Both simplicity and advanced needs can be met effortlessly.

Convert a page with Playwright and Sharp

This Node.js example navigates to a URL, captures the full scrollable page as PNG bytes, encodes those bytes as AVIF, and writes page.avif. Install the packages first with npm install playwright sharp. Playwright browser binaries must also be installed for your environment; follow the current Playwright installation instructions.

const { chromium } = require('playwright');
const sharp = require('sharp');

async function main() {
  const browser = await chromium.launch({ headless: true });

  try {
    const page = await browser.newPage({
      viewport: { width: 1440, height: 900 },
      deviceScaleFactor: 1
    });

    await page.goto('https://example.com', { waitUntil: 'networkidle' });
    const png = await page.screenshot({
      type: 'png',
      fullPage: true
    });

    await sharp(png)
      .avif({ quality: 50, effort: 4 })
      .toFile('page.avif');
  } finally {
    await browser.close();
  }
}

main().catch(error => {
  console.error(error);
  process.exitCode = 1;
});

Replace https://example.com with the target URL. The networkidle navigation condition can be unsuitable for pages that keep network connections open; in that case use a more appropriate readiness condition, such as waiting for a specific selector or for a known delay after navigation. For a page you control, a selector wait is usually more precise than assuming that all network activity will stop.

Capture the viewport or one element instead

For only the visible viewport, omit fullPage: true. To capture a specific element, locate it and call screenshot() on that locator:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const png = await page.locator('#report').screenshot({ type: 'png' });
await sharp(png).avif({ quality: 50, effort: 4 }).toFile('report.avif');

Change #report to a CSS selector present on the page. A selector that matches no element, or an element hidden before capture, will prevent a useful element screenshot; ensure the target exists and is visible before capturing it.

Choose screenshot scale deliberately

Playwright distinguishes CSS-pixel and device-pixel screenshot scales. The example sets deviceScaleFactor: 1; increase it if you need more output pixels per CSS pixel, keeping in mind that the resulting image can be larger and take more time and memory to encode. Full-page extent and pixel scale are separate decisions: fullPage: true captures beyond the viewport, while the device scale controls pixel density. See Playwright’s screenshot API documentation for the current options.

Capture with Chrome’s headless command line

For a quick one-off capture, Chrome can save a page screenshot from the command line. The documented screenshot output is PNG, so convert the captured file with Sharp:

google-chrome --headless --screenshot --window-size=1440,900 https://example.com

Then, with Sharp installed, run:

node -e "require('sharp')('screenshot.png').avif({quality:50,effort:4}).toFile('page.avif').then(() => console.log('Wrote page.avif')).catch(err => { console.error(err); process.exit(1); })"

Chrome writes screenshot.png in the current working directory according to its headless CLI reference. This is convenient for a basic capture; use browser automation when you need explicit control over navigation readiness, element selection, full-page capture or screenshot bytes.

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.

Set AVIF quality and encoding effort

Sharp documents .avif() controls including quality, lossless mode, effort, chroma subsampling and bit depth. Quality is an integer from 1 to 100, with a documented default of 50; effort defaults to 4 and ranges from 0 to 9. These are encoder settings, not guarantees of a particular file size, visual quality or speed. Compare the resulting files using representative pages and your own acceptance criteria before choosing production settings.

  • Quality: choose a value appropriate to the visual detail and file-size requirements of your use case.
  • Effort: higher settings may require more processing; measure encoding time in your own environment rather than assuming a particular trade-off.
  • Lossless: use the encoder’s lossless option when preserving image data is more important than minimizing size.
  • Other controls: consult the current Sharp output options for chroma subsampling and bit-depth settings.

Sharp can return AVIF bytes with toBuffer() or write a file with toFile(). If no explicit output format is selected, Sharp documents that it infers the format from the filename extension; calling .avif() explicitly makes the intended output clear.

Or skip the browser setup

ScreenshotNeo is a screenshot API that returns a rendered screenshot, not an AVIF-conversion endpoint. You can request a supported screenshot and then convert its bytes with Sharp:

Rank #3
NexiGo N680E Pro 4K Webcam with Ring Light, PDAF Autofocus, 1080p 60FPS, Dual Noise-Canceling Mics, Privacy Shutter, USB Plug-and-Play for Zoom, Teams, Twitch, Google Meet
  • 【Unmatched 4K Streaming Quality】The NexiGo N680E Pro has a Sony 1/2.5" 4K sensor for ultra-sharp, true-to-life video beyond standard webcams. Stream smoothly at 1080p 60 fps. Its premium coated lens boosts light transmission and reduces reflections for clearer, more vibrant images. Perfect for content creators and live streamers seeking top-tier performance. Note: Output resolution depends on your camera software (e.g., OBS, PotPlayer).
  • 【PDAF Autofocus & Enhanced Audio Clarity】Keep your audience engaged with advanced PDAF autofocus, delivering faster focusing speed, higher precision, and greater stability than traditional AF systems, no matter how you move. Dual noise-reducing microphones capture your voice clearly by filtering out background noise, ensuring clean, distraction-free conversations and streaming.
  • 【Tri-Tone Adjustable Ring Light】The built-in ring light offers three color temperature modes with a simple touch and stepless brightness control by rotating the outer dial. Brighter than typical webcam lights, the N680E Pro provides soft, glare-free illumination so you can easily achieve the perfect lighting for any space.
  • 【Built-in Privacy Shutter】With a simple USB-A plug-and-play connection, this streaming camera works instantly—no drivers, apps, WiFi, or Bluetooth required. The built-in privacy shutter blocks the lens completely to prevent potential hacking or unwanted access, giving you full control over your privacy at all times.
  • 【Widely Compatible】The NexiGo webcam works with Switch 2 (Please use with your own USB-C to USB-A adapter), Windows 7–11, Mac OS 10.6+, and Chrome OS 29+, supporting all major video conferencing and streaming platforms like Zoom, Teams, Skype, and more. Its flexible clip and 80° FOV allow smooth rotation and wide-angle tilting while staying secure, making it easy to find your ideal angle. A standard 1/4" tripod mount ensures stable setup. Ideal for conferencing, gaming, streaming, recording, and online learning.
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 request options. Convert the returned WebP file to AVIF with Sharp, for example: node -e "require('sharp')('shot.webp').avif({quality:50,effort:4}).toFile('shot.avif')".

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Cookie banners are accepted before capture and known consent platforms, newsletter popups and chat widgets are removed; each step can be turned off.
  • Bot checks, blank pages, failed loads, timeouts and cache hits are not billed; responses identify the page verdict and billing status in headers.
  • An MCP server provides take_screenshot, get_page_info and capture_pdf tools for AI agents.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The output is PNG or WebP, not AVIF

A browser screenshot is only the intermediate capture. Confirm the Sharp conversion ran and that the output call uses .avif() or an AVIF filename extension. The browser’s screenshot file should not simply be renamed to .avif.

The capture is blank or missing page content

Check that navigation completed and that the page had time to render client-side content before capture. Wait for a meaningful selector when possible. Some pages load content only after scrolling; for long pages, use full-page capture and verify that lazy-loaded images have actually appeared before encoding.

The command cannot find Chrome or Playwright’s browser

Install the browser binary required by the chosen route and use the command or executable path appropriate for your operating system. Playwright and system Chrome are separate setups; installing the Playwright package alone may not install a browser binary in every environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Logitech Brio 101 Full HD 1080p Webcam for Streaming and Meetings - Black
  • Compatible with Nintendo Switch 2’s new GameChat mode
  • Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
  • Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
  • Built-In Mic: The built-in microphone lets others hear you clearly during video calls
  • Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works

The script waits indefinitely at network idle

Some pages maintain analytics, streaming or other long-running requests. Replace networkidle with domcontentloaded followed by an explicit selector wait, or use a bounded delay if the page offers no stable readiness signal.

The AVIF file is unexpectedly large or encoding is slow

Output depends on the page dimensions, pixel scale, content and encoder settings. Reduce capture dimensions or adjust AVIF quality and effort, then inspect both appearance and processing cost. No fixed savings percentage or speed advantage can be inferred from the documented options alone.

Performance and reproducibility

Rendering and encoding are separate work. Large full-page captures and higher pixel scales create more image data for the encoder to process; test the actual pages and hardware that matter to your deployment. No benchmark establishes that the CLI or Playwright path is universally faster, or that a specific quality setting produces a particular size.

For repeatable output, pin compatible browser and library versions and keep the viewport, device scale, page state and capture settings consistent. Playwright notes that rendered output can vary with host OS, browser version, settings, hardware, power source and headless mode in its visual comparisons guide. The linked documentation was accessed 2026-10-03; versions and defaults can change, so check the current docs for the versions you install.

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

Frequently Asked Questions

Can I convert a local HTML file rather than a public URL?

Yes. Load the file in the browser with a file URL, or serve it locally and navigate to that address; the same capture-then-encode steps apply.

Does converting to AVIF preserve the page’s text as selectable text?

No. A screenshot is a raster image of the rendered page, not a document retaining the HTML text structure.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.