Recommended Free Tools
To preserve an image’s visible transparency in an html2canvas download, render with backgroundColor: null and serialize the result as PNG: canvas.toDataURL('image/png'). html2canvas applies CSS opacity while painting pixels to a canvas; it does not store a reusable CSS opacity rule in the downloaded file. A JPEG export will flatten transparency, and cross-origin images need a valid CORS response or a proxy.
What html2canvas does with opacity
html2canvas reconstructs the selected DOM in a canvas rather than copying the original image file. During rendering, its CanvasRenderer sets the 2D context’s globalAlpha for opacity effects, then paints image elements with drawImage. The opacity you see in the browser is therefore composited into the canvas pixels during capture.
The downloaded PNG contains those resulting pixel values. It does not retain a CSS declaration such as opacity: .5 that could be edited later. This distinction explains why the screenshot can look correct while the original image’s CSS remains unavailable in the file.
Use a transparent canvas and PNG serialization
This is the smallest reliable pattern for a transparent capture:
#1 Best Overall
- User-Friendly Portable Photo Printer for iPhone, Android & PC - Get beautiful and colourful memories with Liene 4x6 photo printer! After opening the entire package, you can find one cartridge + 20 sheets of photo paper (placed inside the machine packaging), as well as an additional box containing 80 sheets of photo paper (which includes two cartridges + 80 sheets of photo paper). Full package includes smartphone photo printer, Liene 4x6 photo printer papers (100 sheets), 3 colour cartridges, and fully sealed cassette to prevent dust. Minimalist and magnetic design for compact storage.
- Superior Quality 4x6 Photo Printer - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Clean the print head promptly if smudges are observed on printed photos during operation. Get Liene photo printers now for yourself and your loved ones, print your happy moments together and keep your love forever!
- Wi-Fi Photo Printer for Smartphone - The built-in hotspot of the photo printer makes it easy to print pictures from your phone, avoiding outside interference with a fast and stable connection. No other networks required! Simply connect your device to the independent instant photo printer 4x6 hotspot.
- Multiple Device Compatibility - Liene phone printer provides instant photo printing for up to 5 simultaneous connections. Share with family and friends or print from your different devices. No additional cables or Bluetooth required when printing photos with this picture printer. Note: Ensure the ink cartridge clicks into place before printing.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Square border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this photo printer for iphone 4x6 prints.
const target = document.querySelector('#capture');
const canvas = await html2canvas(target, {
backgroundColor: null,
useCORS: true
});
const link = document.createElement('a');
link.download = 'capture.png';
link.href = canvas.toDataURL('image/png');
link.click();
backgroundColor: null makes the canvas outside the captured content transparent. The element’s own CSS opacity, and any opacity inherited from an ancestor, is still applied while html2canvas paints the element. useCORS: true permits CORS-enabled images to be requested, but it cannot override the browser’s same-origin policy.
Complete browser example
<button id="download">Download PNG</button>
<div id="capture" class="card">
<img src="https://cdn.example.com/logo.png" alt="Logo">
<div class="overlay">50% opacity</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/html2canvas@latest/dist/html2canvas.min.js"></script>
<script>
document.querySelector('#download').addEventListener('click', async () => {
const canvas = await html2canvas(document.querySelector('#capture'), {
backgroundColor: null,
useCORS: true,
scale: window.devicePixelRatio
});
const blob = await new Promise(resolve => canvas.toBlob(resolve, 'image/png'));
if (!blob) throw new Error('PNG encoding failed');
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.download = 'capture.png';
link.href = url;
link.click();
URL.revokeObjectURL(url);
});
</script>
toBlob avoids creating a potentially very large data URL. If you need the exact official-style approach, replace the blob section with canvas.toDataURL('image/png') and assign that value to link.href. Both preserve PNG alpha.
Make sure the CSS actually expresses the opacity you want
CSS opacity versus image alpha
A transparent PNG can contain per-pixel alpha in the file itself. CSS opacity then multiplies the entire element, including that existing alpha. An ancestor’s opacity multiplies it again. html2canvas composites the combined result, so inspect both the image file and every relevant ancestor.
.logo {
opacity: 0.5;
}
.card {
opacity: 0.9; /* also affects the logo and all descendants */
}
Transparent surroundings
If the image appears to have a solid rectangle around it, the rectangle may be the canvas background rather than the image. Set backgroundColor: null. A CSS background on the captured element itself is different: html2canvas will paint that background, so remove or override it only if you want that area transparent.
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 →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Export-only changes with onclone
Use onclone when the live page must remain unchanged. html2canvas passes a cloned document to the callback, allowing you to hide controls or adjust export-only styles:
Rank #2
- Dock Photo Printer: The KODAK Dock Plus is a home photo printer that produces high-quality 4x6” prints directly from compatible smartphones. Featuring an integrated docking station, users can place their phone on the printer for better connection while simultaneously charging the device during printing.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Dock Plus is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Home Printing Station: Designed for stable desktop use, this dock photo printer connects to a power outlet for consistent performance and larger 4x6” prints. Ideal for home printing, photo albums, framing, family events, and everyday picture printing.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
const canvas = await html2canvas(document.querySelector('#capture'), {
backgroundColor: null,
onclone: clonedDocument => {
clonedDocument.querySelectorAll('.no-export').forEach(node => {
node.style.display = 'none';
});
const exportImage = clonedDocument.querySelector('.logo');
if (exportImage) exportImage.style.opacity = '0.5';
}
});
Choose an output format that can carry alpha
| Format | Transparency | Use it when |
|---|---|---|
| PNG | Preserved | Any transparent pixels or semi-transparent edges must survive. |
| JPEG | Flattened | You explicitly want a photograph-style image with no alpha channel. |
| WebP | Can preserve alpha, depending on the encoder and consumer | You control the receiving software and want smaller files than PNG. |
For the least surprising browser download, use canvas.toDataURL('image/png') or canvas.toBlob(resolve, 'image/png'). Exporting the same canvas as JPEG creates a background and can make correctly composited edges look opaque.
Handle cross-origin images before capture
Images loaded from another origin are governed by the browser’s CORS policy. The image server must send an appropriate Access-Control-Allow-Origin response header, and the request must be made in a way compatible with that header. With such a response, useCORS: true lets html2canvas use the image. Without it, the image may be skipped or the canvas may become tainted, preventing export.
Preferred fixes
- Serve the image from the same origin as the page.
- Configure the image host to return
Access-Control-Allow-Originfor your site (or an allowed wildcard where appropriate). - Fetch or relay the asset through a server-side, same-origin proxy that you control, then point the page at that proxy URL.
html2canvas cannot bypass this browser security rule. A permissive crossorigin attribute without a matching server header is not sufficient.
PC 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 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWhy the browser view and download can differ
Unsupported or partially supported CSS
html2canvas implements a subset of CSS. Ordinary opacity is rendered through canvas compositing, but filters, blend modes, masks and newer color features may not match the browser’s compositor. If the design depends on one of these, simplify the export-only style in onclone, pre-render the effect into an image, or use a browser capture method that screenshots the compositor output.
Timing and lazy content
Capture only after the image has loaded and any opacity-changing class has been applied. For a single image, await its decode() promise where available:
Rank #3
- 2x3" Portable Photo Printer: The upgraded PP01 photo printer uses advanced inkjet technology. This portable photo printer produces vivid, full-color prints on premium sticky-backed photo paper that is smudge-proof, water-resistant, and tear-resistant. The Nelko mini photo printer is pocket-sized and weighs only 308g, making it ultra-portable for school, travel, and field trips. Each ink cartridge prints up to 80 full-color 2x3 photos on sticky-backed paper
- Easy Printing via Bluetooth: The PP01 mini photo printer is compatible with iOS and Android phones via Bluetooth. Simply download the Nelko app from Google Play or the App Store. Load the 2x3 photo paper with the smooth side facing down. Install the ink cartridge, connect via Bluetooth, and print directly using the Nelko app. A USB charging cable is included; the adapter is not included
- High Photo Quality: This mini photo printer uses advanced inkjet technology for clear, vibrant prints. This portable photo printer produces 600 DPI high-resolution images with precise colors, capturing fine details and realistic tones. Each photo comes with adhesive backing, perfect for scrapbooks and preserving your memories. Personalize every photo for holidays, birthdays, or daily events
- Powerful App: The Nelko 2x3" PP01 photo printer app lets you edit photos and offers a variety of frame designs, making it perfect for personalizing your photos for projects like scrapbooking or journaling. Download the Nelko app to create collages and customize photos with filters, graffiti, borders, stickers, text, AI image editing, and many other features. Edit photos on your phone, then send them to the Nelko app for instant printing in under 90 seconds
- Versatile Usage Scenarios: This portable photo printer is ideal for travel journals, party favors, and family gatherings. Students use it for planners and photo printing. Crafters use it for DIY projects, custom labels, and scrapbooking. It's a practical tool for bloggers, small businesses, and event photographers to create instant giveaways. Perfect for Mother's Day surprises and heartfelt moments with loved ones using Nelko sticky-backed photo paper.
const image = document.querySelector('#capture img');
if (image.complete) {
await image.decode().catch(() => {});
}
const canvas = await html2canvas(document.querySelector('#capture'), {
backgroundColor: null,
useCORS: true
});
For pages that load content after scrolling or interaction, make that content visible first; html2canvas captures the rendered DOM state at the time you call it.
Troubleshooting opacity and download failures
The image looks fully opaque
- Confirm the export is PNG, not JPEG.
- Set
backgroundColor: nullif the surrounding area, rather than the image pixels, appears solid. - Inspect CSS opacity on the image and all ancestors; an unexpected
opacity: 1rule or opaque background may be masking the intended result. - Check whether the source file itself has an alpha channel. CSS opacity cannot create holes inside an otherwise opaque bitmap.
The image is missing
- Open the image URL directly and check the response headers for CORS permission.
- Use
useCORS: trueand ensure the image is requested with a compatiblecrossoriginsetting. - Move the asset to the page’s origin or use a same-origin proxy.
- Wait for the image to load before calling html2canvas.
toDataURL throws a security error
The canvas is tainted, usually because a cross-origin image was drawn without a valid CORS response. Fix the image delivery or proxy it; changing serialization code cannot untaint an already-rendered canvas.
Edges look different from the page
Check filters, blend modes, masks and color functions that html2canvas may not implement. Compare a plain-opacity version. If plain opacity matches but the effect does not, use an export-only fallback or a compositor-level screenshot tool.
The file is too large or capture is slow
Canvas memory grows with pixel dimensions. A high scale (such as device-pixel ratio) improves detail but increases rendering time and file size. Choose the smallest scale that meets your use case, capture only the required element, and prefer toBlob for download handling.
When html2canvas is the right method
| Requirement | html2canvas fit | What to verify |
|---|---|---|
| Preserve CSS opacity in a DOM element | Good for supported CSS | Use PNG and transparent background settings. |
| Original image bytes and metadata | Not the goal | Download the source image instead of a DOM rendering. |
| Cross-origin assets | Conditional | Valid CORS headers or a proxy are required. |
| Exact browser rendering of advanced effects | May differ | Check filters, masks, blend modes and newer CSS. |
| Repeatable server-side captures | Usually better handled elsewhere | Use a browser service or automation environment with explicit options. |
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP or PDF, and its capture pipeline accepts cookie and consent banners before removing more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed; each response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients.
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 transparent backgrounds, full-page and element captures, custom CSS and JavaScript, waits, request blocking, headers and cookies, device presets, retina scale, caching, signed links, asynchronous jobs, bulk capture and PDF controls.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #4
- Dual 4x6" & 3x3" Photo Printer Paper Tray Convenience: Seamlessly print both 6-inch standard photo paper and 3-inch sticky-backed paper with our innovative dual tray design. This compact phone photo printer for smartphone offers easy storage and quick access, making it perfect for diverse printing needs without taking up much space. Enjoy vibrant, high-quality prints every time.
- Fast Bluetooth Connectivity: Experience lightning-fast printing with our liene photo printer's Bluetooth connection, which pairs in just 13 seconds. Enjoy a seamless and efficient printing experience, perfect for capturing and sharing memories on the go without the hassle of cables or complex setups.
- Superior Quality Photo Printer 4x6 - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Get Liene photo printers now as amazing gifts for yourself and your loved ones, print your happy moments together and keep your love forever!
- Multiple Device Compatibility - Liene picture printer for iphone provides instant photo printing for up to mutiple simultaneous connections. Share with family and friends or print from your different devices. No additional cables required when printing photos with this phone printer.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Polaroid border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this iphone photo printer for 4x6 & 3x3 prints.
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)
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 shots 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.FAQ
Does html2canvas preserve the original CSS opacity value?
No. It preserves the visual result by compositing opacity into canvas pixels.
Can a transparent JPEG be downloaded?
No. JPEG has no alpha channel; use PNG when transparency matters.
Will backgroundColor: null remove a background set in CSS?
It makes the canvas default background transparent. A background painted by the captured element remains unless you remove it in an export-only clone.
Why does a CORS-enabled image still fail?
The response header, request mode and image origin must all agree. If the server does not authorize your page, use a same-origin proxy.
Best Value
- Instant Photo Printing: The KODAK Mini 2 Retro is a portable photo printer designed to turn smartphone pictures into high quality prints in seconds. Whether capturing family moments, travel highlights, journaling pages, or creative projects, this mini printer lets you print real photos anytime, anywhere.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Mini 2 Retro is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Print Anytime, Anywhere: Small enough to fit in your hand, bag, or even a pocket, the Mini 2 Retro is built for on-the-go printing. Ideal for parties, trips, school projects, scrapbooks, and spontaneous moments where you want real prints without waiting.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
Frequently Asked Questions
Does html2canvas preserve the original CSS opacity value?
No. It preserves the visual result by compositing opacity into canvas pixels.
Can a transparent JPEG be downloaded?
No. JPEG has no alpha channel; use PNG when transparency matters.
Will backgroundColor: null remove a background set in CSS?
It makes the canvas default background transparent. A background painted by the captured element remains unless you remove it in an export-only clone.
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 glitchesWhy does a CORS-enabled image still fail?
The response header, request mode and image origin must all agree. If the server does not authorize your page, use a same-origin proxy.
The Bottom Line
Render with backgroundColor: null, export as PNG, and resolve CORS before capture. That preserves the opacity html2canvas can reproduce; advanced CSS effects and cross-origin restrictions still require separate handling.
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.

