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.

The reliable fix is a two-part CORS handshake: set crossorigin="anonymous" (or img.crossOrigin = "anonymous") before the image request starts, and configure the image server to return an Access-Control-Allow-Origin value that permits your page. Then reload the image and draw it on a new canvas. If the server cannot grant permission, proxy or re-host the asset, avoid canvas pixel readback, or capture the rendered page without exporting canvas pixels.

Why an image can appear in a screenshot but still fail in JavaScript

Browsers separate displaying an image from reading its pixels. An image hosted on another origin can usually be painted into the page. However, when that image is drawn into a canvas without a successful CORS exchange, the canvas becomes tainted. Security restrictions then reject getImageData(), toBlob(), toDataURL() and captureStream(), typically with a security exception.

This explains the common screenshot paradox: Playwright or Puppeteer may produce a screenshot that visibly contains the image, while code that exports a canvas or processes its pixels fails. Screenshot automation does not override browser origin security; the page still obeys normal CORS and canvas rules.

Understand origins before changing code

Compare the complete URL, not just the company name. A different scheme (http versus https), hostname, port, CDN, redirect destination or asset host is a different origin. The same applies to:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Anker USB C to HDMI Adapter (4K@60Hz), USB Type C to HDMI Cable Adapter
  • The Anker Advantage: Join the 80 million+ powered by our leading technology.
  • Vivid Video: The HDMI adapter lets you connect to any TV or display with an HDMI port to stream video in up to 4K resolution.
  • Plug and Play: Instantly turn your laptop’s USB-C port into an HDMI port, with no installation necessary. This product does not support charging or Power Delivery (PD).
  • Premium Construction: A lightweight aluminum casing allows for greater heat dissipation, while the reinforced braided-nylon cable is designed to withstand the twists and tugs of daily use.
  • Compatibility: Supports USB-C DP Alt mode, USB4, and Thunderbolt connections.
  • CSS background-image URLs and responsive srcset candidates.
  • SVG <image> resources.
  • Fonts, embedded charts and third-party widgets that draw into the same canvas.
  • Redirects: the final image response must provide the appropriate CORS headers.

In browser developer tools, inspect the actual request and its final response. Do not assume that an image URL which looks local is served by your origin.

Repair the image request and server response

1. Set CORS mode before loading

With markup, put the attribute on the image before its src request begins:

<img id="hero" crossorigin="anonymous" src="https://cdn.example/image.png" alt="Example">

With JavaScript, assign crossOrigin first. Setting it after src starts loading is too late:

const img = new Image();
img.crossOrigin = "anonymous";
img.onload = () => drawAndExport(img);
img.onerror = (event) => console.error("Image failed CORS loading", event);
img.src = "https://cdn.example/image.png";

function drawAndExport(img) {
  const canvas = document.createElement("canvas");
  canvas.width = img.naturalWidth;
  canvas.height = img.naturalHeight;
  const context = canvas.getContext("2d");
  context.drawImage(img, 0, 0);
  context.getImageData(0, 0, 1, 1); // proves pixel readback is allowed
  canvas.toBlob(blob => {
    if (!blob) throw new Error("Browser returned no image blob");
    console.log("Export succeeded", blob.type);
  }, "image/png");
}

2. Return an allowing header from the image host

The image response must include Access-Control-Allow-Origin for the requesting site. For a public asset, the server may deliberately allow a broad policy; for a controlled application, return the specific site origin. If the request includes credentials, use a credentialed CORS configuration and do not combine credentials with a wildcard origin policy.

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

A header on your HTML page does not grant permission to a remote image. The asset server (or a proxy you control) must opt in. Also make sure that redirects, CDN cache variants and error responses preserve the intended header. When responses vary by origin, configure the cache to vary on the Origin request header so one site’s response is not reused for another.

Rank #2
BENFEI USB C to HDMI Adapter 4K@60Hz, USB Type-C to HDMI Adapter [Thunderbolt 3/4/5 Compatible] with iPhone 15 Pro/Max, MacBook Pro/Air 2023, iPad Pro, iMac, S23, XPS 17, Surface Book
  • COMPACT DESIGN - The compact-designed portable BENFEI USB-C to HDMI adapter connects a computer, desktop, laptop, or other devices with USB-C port to a monitor, projector, HDTV, or other devices with HDMI port; Tuck this lightweight gadget into your bag or pocket to do a business presentation with your laptop and projector, or extend your desktop screen to a monitor or TV;
  • SUPERIOR STABILITY - Built-in advanced IC chip converts USB-C digital signal to HDMI signal; Please pay attention, the USB-C device should support the USB Type-C DP Alt mode.
  • INCREDIBLE PERFORMANCE - The USB-C to HDMI adapter supports resolutions up to 3840*2160@60Hz including, 3840*2160@30Hz, 2K@144Hz, 1080P, 720p, 1600x1200, 1280x1024 for high definition monitors or projectors; Plated USB-C connector resists corrosion and abrasion and improve the signal transmission performance; Molded strain relief increases cable durability
  • BROAD COMPATIBILITY - The BENFEI USB-C to HDMI is compatible with iPhone 15 Pro/Max, 13"/15" MacBook Pro/Air, iMac,2023,2022,2021, 2020, 2019, Google Chromebook Pixel, Yoga 900, Dell XPS 13 (9350), Dell XPS 15 9550, Dell XPS12 9250, DellPrecision 5510, HP Spectre X2, HP Spectre x360, HP Elitebook Folio G1, HP Elite x2 1012 G1, Acer Switch Alpha 1, Acer Spin 7, Acer Chromebook R13, Samsung Chromebook Plus, Samsung Galaxy TabPro S,Samsung Galaxy A7 2017, LG G5, LG V20, HTC 10
  • 18 MONTH WARRANTY - Exclusive BENFEI Unconditional 18-month Warranty ensures long-time satisfaction of your purchase; Friendly and easy-to-reach customer service to solve your problems timely Compare with similar items

3. Reload into a new canvas

Changing server headers cannot cleanse an existing bitmap. Discard the old image and canvas, start a new CORS-enabled request, and draw the newly loaded image into a newly created canvas. Test the exact operation your application needs: getImageData, toBlob, toDataURL or captureStream.

When you do not control the image host

A browser cannot manufacture CORS permission. Choose one of these paths:

Situation Practical solution Trade-off
Public image, pixel processing required Ask the owner to enable CORS, or fetch and serve the asset from an origin you control. You assume proxy bandwidth, caching and abuse-prevention responsibilities.
Private or credentialed image Use an authorized server-side fetch or API, then expose only what your application is permitted to use. Requires authentication design; never expose private credentials in client code.
Only a visual screenshot is required Capture the rendered page or element; do not read the image through canvas. You receive pixels, but cannot inspect or transform them in page JavaScript.
Third-party widget or background image Remove it from the canvas workflow, self-host an authorized copy, or obtain a CORS-capable provider. Self-hosting can change update and licensing responsibilities.

Canvas and screenshot automation examples

Playwright: capture the rendered page

Use this when the deliverable is a visual screenshot rather than a canvas export. The browser still enforces CORS, but Playwright can capture what was rendered.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage({ deviceScaleFactor: 1 });
page.on('console', message => console.log('browser:', message.type(), message.text()));
page.on('requestfailed', request => console.error('request failed:', request.url(), request.failure()));
await page.goto('https://example.com/gallery', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'gallery.png', fullPage: true });
await browser.close();

Playwright supports viewport, element, full-page and device-scale screenshots. Wait for the image or a known selector when lazy loading is involved. Save console and failed-request logs in CI so a missing asset is distinguishable from a canvas readback error.

Puppeteer: capture the rendered page

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();
page.on('console', message => console.log('browser:', message.text()));
page.on('requestfailed', request => console.error('request failed:', request.url(), request.failure()?.errorText));
await page.goto('https://example.com/gallery', { waitUntil: 'networkidle0' });
await page.screenshot({ path: 'gallery.png', fullPage: true });
await browser.close();

If your script instead calls page.evaluate(() => canvas.toDataURL()), that call still fails when any drawn resource lacks CORS approval. Fix the request/server pair or stop using canvas readback.

Rank #3
Sale
Highwings USB C to HDMI Adapter for Home Office (4K@60Hz) for Laptop
  • CHECK YOUR DEVICE FIRST( USB-C MALE TO HDMI FEMALE): This adapter works with USB Type C ports that support DP Alt Mode. Want to be sure before you buy? Check your device specs - not every USB-C port sends video.
  • ONE-WAY VIDEO & AUDIO OUTPUT: This adapter sends video and audio from your USB-C device to an HDMI display. It does not support charging, and it is not designed for HDMI-to-USB-C direction.
  • 4K@60Hz USB-C TO HDMI ADAPTER CABLE: Get clear 4K picture at 60Hz from a compatible USB-C laptop or tablet. It also works with older HDMI 1.4, 1.3 and 1.2 screens.
  • PLUG AND PLAY, NO SETUP: Turn your USB-C port into an HDMI port with no drivers and no installation. What you see depends on your device and your screen.
  • EXTEND YOUR REACH: Going from USB-C male to HDMI female lets you keep using the HDMI cable you already have, and place your laptop or phone where you want it.

Diagnose the failure systematically

  1. Find the real URL. Record the requested URL, redirect chain, scheme, host and port. Check CSS, SVG and widget resources as well as ordinary <img> tags.
  2. Inspect the response. Confirm Access-Control-Allow-Origin on the final image response and, for credentialed requests, the corresponding credentials header. A missing header, a mismatched origin or a cached wrong variant is a server-side problem.
  3. Check request order. Verify that crossorigin or crossOrigin was set before src, including before a framework’s image component starts loading.
  4. Recreate state. Reload the image and create a fresh canvas after the server fix. Do not reuse a bitmap or canvas that was already tainted.
  5. Test the failing API. A successful visual screenshot does not prove that pixel readback is legal. Test the exact export or processing method.
  6. Capture evidence in CI. Store browser console output, network failures and the screenshot together. This distinguishes a blocked image load from a perfectly valid visual capture with an invalid canvas export.

Common errors and precise fixes

“The image displays, but getImageData is blocked”

The image was likely loaded without CORS and then drawn to the canvas. Add crossorigin="anonymous" before loading, enable the response header, and redraw on a new canvas.

“Setting crossOrigin did nothing”

It was probably assigned after src, or a framework had already initiated the request. Set the property in the image factory or component configuration before any URL assignment; then force a fresh request.

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

“CORS error appears and the image is now missing”

Adding crossorigin changes a non-CORS request into a CORS request. If the server does not opt in, the browser blocks the load. Remove the attribute only when you need display-only behavior, or fix the server/proxy so the CORS request succeeds.

“It works locally but fails in CI”

Compare the exact page origin, protocol, redirects, credentials, CDN cache and user-agent behavior. CI may use a different origin or receive a cached response without the required header. Log response headers and final URLs in the failing environment.

“Only one image taints a collage”

Any non-CORS resource drawn into the canvas can taint the entire canvas. Audit every layer, including backgrounds, SVG references, fonts and third-party components.

Rank #4
Sale
Acer USB C Hub, 5-in-1 USBC to HDMI Adapter with 4K@60Hz for Laptop/Mac
  • 【5-in-1 Ultimate Productivity HUB】Expand your USB-C port into a high-performance workstation. This usb c hub multiport adapter integrates 4K@60Hz HDMI, 100W PD, USB-C 3.0 (5Gbps), USB-A 3.0/2.0. Perfect for keeping your desk organized and eliminating clutter from multiple dongles.
  • 【True 4K@60Hz Visual Feast】Stop settling for blurry 30Hz displays. This USB-C to HDMI adapter supports 4K@60Hz, delivering 2X the smoothness of standard hubs. Ideal for pro video editing, high-stakes presentations, or immersive 4K streaming without motion blur.
  • 【100W Pass-Through Fast Charging】Equipped with a high-speed PD 3.0 chip, this usb c to usb adapter supports up to 100W input and provides a stable 90W output to your laptop. Stay powered up during intensive tasks like 3D rendering or long meetings—say goodbye to low-battery anxiety once and for all. 📌Note: For optimal 90W charging, a 100W power adapter and cable are recommended (not included).
  • 【Hyper-Speed 5Gbps Data Transfers】Move massive files in seconds! Featuring both USB-C and USB-A 3.0 ports (5Gbps), this usb c hub for laptop is 10X faster than USB 2.0. The additional USB 2.0 port is optimized for wireless mice and keyboards, ensuring a stable connection with zero interference.
  • 【Superior Cooling & Ultra-Portable Design】Built with a durable aluminum shell, this docking station improves heat dissipation for reliable use. Its ultra-slim, lightweight design slips easily into your bag—perfect for travel, office, or remote work essentials.

Performance, reliability and security considerations

For visual screenshots, waiting for network idle can be slower than waiting for a specific image selector; choose the narrowest condition that guarantees the content is present. Full-page captures may trigger lazy-loaded images, so verify that the page has scrolled or that your tool’s full-page behavior loads them as expected. Repeatedly proxying large images adds bandwidth and latency; cache authorized public assets while preserving correct origin variation.

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

Do not “fix” CORS by disabling browser security in production automation, shipping permissive development flags to users, or exposing private image credentials. Those approaches hide the policy violation rather than creating a safe permission exchange.

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

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. It captures the rendered page without requiring you to configure a local browser, and its cleanup steps remove cookie/consent banners, newsletter popups and chat widgets before capture. Bot checks, blank pages, failed loads and timeouts are not billed, and response headers identify the page verdict and billing status.

One GET request returns PNG, JPEG, WebP or PDF. The same endpoint supports full-page and element captures, device and viewport settings, waiting rules, custom headers and cookies, JavaScript, request blocking, geolocation, dark mode, retina scale and other options. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

See the complete parameter reference in the ScreenshotNeo documentation. This cURL example captures a page directly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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}`);

The Free plan includes 1,000 screenshots per month without a card. Paid plans start at $5 for 3,000 screenshots; every feature is included on every plan. Create a free ScreenshotNeo account to try the capture API.

Best Value
Warrky USB C to HDMI Cable 6FT for Home Office 4K@60Hz High-Speed 4K HDMI
  • [Effortless Plug & Play] Crystal-clear and vibrant 4K@60Hz resolution backward compatible for 1440P/2K@144Hz and 1080P@240Hz. Instantly mirror or extend UHD content from your Type-C phone, tablet, laptop, and desktop computer to larger displays like monitors, TVs, and projectors. Leave behind the worries of unstable WiFi and the hassle of drivers. HDCP compliance lets you enjoy media streaming without any limitations.𝗣𝗹𝗲𝗮𝘀𝗲 𝗡𝗼𝘁𝗲: 𝗧𝗵𝗶𝘀 𝗶𝘀 𝗮 𝗼𝗻𝗲-𝘄𝗮𝘆 𝗰𝗮𝗯𝗹𝗲, 𝗱𝗲𝘀𝗶𝗴𝗻𝗲𝗱 𝗲𝘅𝗰𝗹𝘂𝘀𝗶𝘃𝗲𝗹𝘆 𝗳𝗼𝗿 𝘁𝗿𝗮𝗻𝘀𝗺𝗶𝘀𝘀𝗶𝗼𝗻 𝗳𝗿𝗼𝗺 𝗨𝗦𝗕-𝗖 𝗵𝗼𝘀𝘁 𝗱𝗲𝘃𝗶𝗰𝗲𝘀 𝘁𝗼 𝗛𝗗𝗠𝗜 𝗱𝗶𝘀𝗽𝗹𝗮𝘆𝘀.
  • [Exquisite Craftsmanship] Every detail is meticulously designed for excellence: The gold-plated connector ensures secure and high-speed data transmission, delivering interference-free performance. The uni-body molding ensures an unbreakable connection, while the aluminum case efficiently dissipates heat for extended usage. The thicker copper wire minimizes signal loss, providing maximum conductivity for an impeccable audio-visual experience.
  • [Intricate Design] Elevate your experience with impeccable materials. The nylon braided cable jacket offers worry-free usage, eliminating concerns of fraying, heating, or kinking. The non-slip thumb grip provides a comfortable and secure plug-in experience. The streamlined metal pieces seamlessly connect, offering shock-proof reliability. Bonus Velcro tie adds convenience for travel. The stylish gray metallic case with a hint of blue embodies elegance and sophistication.
  • [Extensive Compatibility] Designed for Type C ports with video output capability (DP Alt Mode) and Thunderbolt 3 & 4. Enjoy compatibility with a wide range of devices, including iPhone 15/16/17 Series, MacBook Neo, Apple MacBook Pro (2016 and later), iMac (2017 and later), MacBook Air (2018 and later), iPad Pro (2021 and later), Mac Studio, Mac Pro, Surface Book 2/3, Surface Laptop 3, Dell XPS 15/13, HP Chromebook x360, Samsung Galaxy S23/S22/S21/S20/S10/S9/S8, Note 20/10/9/8, LG V40, Steam Deck, and more.
  • [WARRKY: Elevating Connections in Work and Life] Provides superb-quality products that harmonize sophistication and affordability, helping you enhance both your work and personal life. We are committed to delivering fast and responsive support within 18 hours. Please consult WARRKY anytime.

Frequently Asked Questions

Does adding an HTTP CORS header to my web page fix a remote image?

No. The image response itself, or a proxy response you control, must provide the allowing header.

Can I make a tainted canvas clean by changing its properties?

No. Reload the image with a successful CORS request and draw it into a new canvas.

Is a screenshot that contains the image proof that CORS is configured correctly?

No. Visual painting can succeed while canvas pixel readback remains forbidden.

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

Do cookies always require credentialed CORS?

Only when your image request actually sends credentials. If it does, configure an explicit credentialed policy rather than a wildcard origin.

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.