Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Use the element itself as html2canvas’s input, then decide whether “zoom” means a CSS transform, browser zoom, or higher output density. Select the enlarged element, capture it with html2canvas(target, options), and set scale deliberately: window.devicePixelRatio produces a sharper density-aware image, while 1 preserves CSS-pixel dimensions. Browser zoom changes devicePixelRatio, so read it at capture time.
What “zoomed” means in html2canvas
Three different mechanisms are commonly called zoom. They require different handling:
| Zoom mechanism | What changes | Capture decision |
|---|---|---|
CSS transform: scale() |
The element is visually enlarged, but its normal layout box may remain smaller. | Keep the transform if the enlarged appearance is wanted; otherwise remove it in onclone. |
| Browser/page zoom | CSS pixel mapping and window.devicePixelRatio change. |
Inspect window.devicePixelRatio and choose density-aware or CSS-pixel output. |
| Higher bitmap resolution | The canvas receives more internal pixels without changing the page’s layout. | Increase scale, accepting higher memory use and larger files. |
html2canvas reconstructs a picture from DOM and CSS information in the browser; it is not a native operating-system screenshot. Only CSS properties the renderer understands can appear in the result, and cross-origin browser restrictions still apply.
Basic capture of the enlarged element
Pass the target element, not the whole document, to html2canvas. This example preserves a transparent background and uses the display density that exists at capture time.
#1 Best Overall
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 4x optical zoom with a 27mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen with 2 AA alkaline batteries for convenient on-the-go use
const target = document.querySelector('.zoomed-element');
if (!target) {
throw new Error('The .zoomed-element element was not found');
}
const canvas = await html2canvas(target, {
scale: window.devicePixelRatio,
backgroundColor: null,
});
const png = canvas.toDataURL('image/png');
const link = document.createElement('a');
link.href = png;
link.download = 'zoomed-element.png';
link.click();
Run this after the element exists and after its fonts and images have loaded. A scale of 2 creates approximately twice the pixels in each direction (about four times as many total pixels), so memory use rises quickly.
Capture only a precise region
For a crop that must match a particular CSS box, derive dimensions from the element’s current geometry. getBoundingClientRect() reports the post-transform visual bounds, which is useful when the transformed appearance is the desired result.
const target = document.querySelector('.zoomed-element');
if (!target) throw new Error('Target not found');
const rect = target.getBoundingClientRect();
const canvas = await html2canvas(target, {
x: 0,
y: 0,
width: Math.ceil(rect.width),
height: Math.ceil(rect.height),
scale: window.devicePixelRatio,
});
The x, y, width, and height values are capture coordinates for the rendered element or document. If you instead render a larger document and crop it, calculate coordinates in that document’s coordinate system. Fractional dimensions should be rounded up to avoid clipping a final row or column.
Off-screen and scrolling content
Content outside the viewport can be included by giving html2canvas a virtual window large enough to contain it. Fixed-position controls may depend on scroll state, so provide scrollX and scrollY that match the state you intend to reproduce.
const canvas = await html2canvas(target, {
windowWidth: Math.max(document.documentElement.scrollWidth, window.innerWidth),
windowHeight: Math.max(document.documentElement.scrollHeight, window.innerHeight),
scrollX: window.scrollX,
scrollY: window.scrollY,
scale: window.devicePixelRatio,
});
Large virtual dimensions can exceed browser canvas limits. If the output is blank, clipped, or the promise fails only for long pages, reduce the region, lower scale, or capture several sections.
When CSS transform zoom produces surprising bounds
A transformed element can look larger than its layout box. Compare both geometries before choosing a crop:
Rank #2
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
const target = document.querySelector('.zoomed-element');
const layout = {
width: target.offsetWidth,
height: target.offsetHeight,
};
const visual = target.getBoundingClientRect();
console.table({
layoutWidth: layout.width,
layoutHeight: layout.height,
visualWidth: visual.width,
visualHeight: visual.height,
});
Use the visual rectangle when the exported image should show the zoomed presentation. Use the normal layout dimensions when you want the component’s untransformed box. Transforms can still create unexpected clipping or whitespace, especially when the transform origin is centered.
Normalize the clone without changing the live page
onclone runs after html2canvas clones the document and before rendering. It is the safest place to remove a presentation-only transform, set a stable origin, hide buttons, or apply capture-only styles. The live page is untouched.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →const target = document.querySelector('.zoomed-element');
const canvas = await html2canvas(target, {
scale: window.devicePixelRatio,
onclone: (clonedDocument) => {
const cloneTarget = clonedDocument.querySelector('.zoomed-element');
if (!cloneTarget) return;
cloneTarget.style.transform = 'none';
cloneTarget.style.transformOrigin = 'top left';
cloneTarget.style.width = `${target.offsetWidth}px`;
cloneTarget.style.height = `${target.offsetHeight}px`;
},
});
Do not normalize the transform if the enlarged visual state is the actual result you need. In that case, leave the transform in place and size the capture from the transformed bounds.
Choosing a scale for sharpness and predictable dimensions
| Goal | Recommended setting | Trade-off |
|---|---|---|
| Match CSS-pixel dimensions exactly | scale: 1 |
Predictable size, but less density on high-DPI displays. |
| Sharp output on the current display | scale: window.devicePixelRatio |
Sharper image, larger canvas and greater memory use. |
| Fixed export size across machines | Use an explicit value such as 2, based on your output contract. |
May be too large for small screens or insufficient for very dense displays. |
Browser zoom affects window.devicePixelRatio. Never assume it is always 1. Log the value during capture if users report inconsistent dimensions:
console.log({
devicePixelRatio: window.devicePixelRatio,
viewportWidth: window.innerWidth,
viewportHeight: window.innerHeight,
});
For very large captures, lower the scale before increasing browser limits or redesigning the export. A high scale multiplies pixels in both dimensions and can exhaust memory even when the CSS box appears modest.
Images, fonts, and cross-origin content
External images
Use useCORS: true only when the image server returns a response that permits your origin. Otherwise, images may be skipped, or the canvas can become tainted and reject toDataURL() and toBlob(). A same-origin proxy is the alternative when you control a server that can fetch and relay the assets.
Rank #3
- Latest Digital Camera Built-in Fill Light : This compact digital camera is paired with a powerful CMOS processor and image stabilization to help you take & record the most exciting moments in 44 MP quality images & FHD 1080P quality videos anywhere, anytime. Plus, there is also a built-in fill light to help you take high quality pictures even in low light&dark settings, making this the perfect camera for all indoors/outdoors situations.
- Long-Lasting Battery Life & 16X Digital Zoom :This point and shoot camera will retain its battery charge even after long use. The controls and functions are easy to operate making this the perfect choice for children, teens and younger. This kids camera supports 16x digital zoom, you can zoom in or out the subject by pressing the W/T button for taking still photos to zoom in or out on distant objects and capture all the details you need.
- Multifunctional & Portable Digital Camera: This cheap digital camera is slim enough to fit in your pocket. You'll easily be able to take it with you on all your indoor/outdoor activities and adventures and ideal for beginners, children and teenagers. This kids digital camera is equipped with 20 filters, anti-shaking, self-timer, continuous shooting, date stamp, time-lapse recording, smile capture, internal MIC and speaker (recording sound videos), great for your daily photography needs.
- WEBCAM & PAUSE FUNCTION : More than just a FHD 1080p digital camera, it also works as a webcam for video calls and vlogging. Connect the camera to the computer, press shutter and power button at the same time and the camera will automatically turn on webcam mode for all your video calling and live streaming needs. The pause function allows you to pause when seeing playback videos.
- A Must Have Photography Device : This digital camera with SD card made from high-quality materials, this retro camera is safe and durable. Perfect for all ages to develop & improve their photographic abilities and observation skills. Our dedicated and experienced 24/7 support team is available for all after purchase troubleshooting, questions and technical help.
const canvas = await html2canvas(target, {
useCORS: true,
scale: window.devicePixelRatio,
});
canvas.toBlob((blob) => {
if (!blob) throw new Error('Canvas export failed');
// Upload blob or create an object URL here.
}, 'image/png');
Do not treat allowTaint as a way to bypass browser security; a tainted canvas still cannot be read back safely.
Wait for fonts and images
Capture after the browser has finished loading resources. A fallback font can change line breaks and element height, while an image that has not decoded can be absent from the clone.
await document.fonts.ready;
const images = [...document.images];
await Promise.all(images.map((img) => {
if (img.complete) return img.decode?.().catch(() => {});
return new Promise((resolve) => {
img.addEventListener('load', resolve, { once: true });
img.addEventListener('error', resolve, { once: true });
});
}));
const canvas = await html2canvas(target, { scale: window.devicePixelRatio });
Advanced renderer and page-state considerations
Where supported, foreignObjectRendering can change visual fidelity because the browser handles more of the HTML and CSS inside an SVG foreign object. It is not universally supported, so test the exact browsers you ship to. Compare it with the ordinary DOM renderer when complex CSS is important.
- Capture a stable state: pause animations, close menus, and wait for asynchronous content.
- Hide capture controls in
onclonerather than changing the user’s page. - Keep the element’s background explicit if transparency is not wanted; otherwise use a color such as
'#ffffff'. - Expect unsupported CSS, cross-origin iframes, and browser canvas limits to produce differences from a native screenshot.
Cross-origin iframes cannot be read because their contentDocument is inaccessible. Capture the iframe’s own page separately, or arrange a same-origin integration.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsComplete reusable helper
This helper waits for resources, optionally removes a transform in the clone, and returns a PNG blob.
async function captureZoomedElement(selector, {
densityAware = true,
normalizeTransform = false,
transparent = true,
} = {}) {
const target = document.querySelector(selector);
if (!target) throw new Error(`No element matches ${selector}`);
await document.fonts.ready;
await Promise.all([...target.querySelectorAll('img')].map(async (img) => {
if (!img.complete) {
await new Promise((resolve) => {
img.addEventListener('load', resolve, { once: true });
img.addEventListener('error', resolve, { once: true });
});
}
if (img.decode) await img.decode().catch(() => {});
}));
const canvas = await html2canvas(target, {
scale: densityAware ? window.devicePixelRatio : 1,
backgroundColor: transparent ? null : '#ffffff',
onclone: normalizeTransform ? (doc) => {
const clone = doc.querySelector(selector);
if (clone) {
clone.style.transform = 'none';
clone.style.transformOrigin = 'top left';
}
} : undefined,
});
return new Promise((resolve, reject) => {
canvas.toBlob((blob) => blob ? resolve(blob) : reject(new Error('toBlob returned null')), 'image/png');
});
}
const blob = await captureZoomedElement('.zoomed-element');
const url = URL.createObjectURL(blob);
window.open(url, '_blank');
Troubleshooting common failures
| Symptom | Likely cause | Fix |
|---|---|---|
| Output is blurry | Internal scale is too low. | Use window.devicePixelRatio or an explicit higher scale; check memory limits. |
| Output dimensions vary with browser zoom | devicePixelRatio changes with zoom. |
Use scale: 1 for CSS-pixel consistency, or document density-aware dimensions. |
| Only part of a transformed element appears | Layout and visual bounds differ. | Inspect getBoundingClientRect(), adjust crop values, or normalize the clone. |
| Images are missing | Image requests lack CORS permission or were not loaded. | Enable server CORS and useCORS: true, use a same-origin proxy, and await decoding. |
toDataURL() throws a security error |
The canvas is tainted by cross-origin content. | Serve assets with appropriate CORS headers or remove/ proxy them. |
| Text wraps differently | Fonts were not ready when the clone was rendered. | Await document.fonts.ready and capture after layout stabilizes. |
| Blank or clipped huge capture | Browser canvas dimension or memory limit. | Reduce region or scale, split the capture, and test on target browsers. |
| Iframe content is absent | Cross-origin iframe isolation. | Capture the iframe separately or make the content same-origin. |
Or skip the browser setup
If you need a URL screenshot rather than a DOM canvas inside your own page, ScreenshotNeo provides a one-request API. It accepts the consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server gives Claude, Cursor, and other MCP clients take_screenshot, get_page_info, and capture_pdf tools.
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 documentation for all options, including viewport and device presets, retina scale, full-page lazy-image loading, CSS-selector element capture, dark mode, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous webhooks, PDF output, bulk capture, usage data, and the OpenAPI specification. Existing parameter names used by other screenshot APIs also work, which can simplify migration.
Rank #4
- 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
- Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
- Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
- Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
- LCD Screen and Battery: 2.7in LCD screen and a rechargeable lithium-ion battery for on-the-go use
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
The free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account to try it.
Recommended Free Tools
FAQ
Should I capture the element or the whole page?
Pass the element when the deliverable is only the enlarged component. Render the document only when surrounding layout, fixed controls, or page context must be included.
Does html2canvas capture a browser’s native zoom level?
It captures the DOM as laid out in the current browser state. Because browser zoom changes pixel density, inspect devicePixelRatio and choose a scale policy instead of assuming native screenshot dimensions.
Can I read pixels from a page containing a third-party image?
Only when the image response permits your origin or is served through a same-origin proxy. Otherwise browser security can prevent pixel export.
Frequently Asked Questions
Can CSS filters and every modern CSS property be reproduced?
No. html2canvas renders the CSS properties it understands, so advanced or unsupported properties may differ from the live page. Test the browsers and styles that matter to your application.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
What format should I use for a transparent capture?
Use backgroundColor: null and export PNG or another format that supports transparency. JPEG cannot preserve transparent pixels.
Why does a clone-only style not appear on my live page?
That is expected: onclone edits the cloned document used for rendering, leaving the live DOM unchanged.
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.




