PNG Export

Export any DOM element to a PNG download — exportElementAsPng from src/lib/png-export.js

OPTIONAL PEER DEPENDENCY
png-export dynamically imports html2canvas at runtime. If it is not installed the function will throw with a clear error message.

Install before using:
npm install html2canvas

This demo loads html2canvas from a CDN so no local install is required. In a production bundle, install it as a project dependency (not a devDependency).

Export Demo

Click "Export as PNG" to capture the card below and download it as a file. Open the browser's Network tab to confirm html2canvas loaded from CDN.

CORRUPTED SIGNAL

アイウエオ · Neural core stability: 42%

0.2.0 @whykusanagi/corrupted-theme png-export
// Install peer dep first:  npm install html2canvas
import { exportElementAsPng } from '@whykusanagi/corrupted-theme/png-export';

const el = document.getElementById('my-card');

// Default: scale=2, transparent background, filename="export.png"
await exportElementAsPng(el);

// With options
await exportElementAsPng(el, {
  filename:        'corrupted-card.png',
  scale:           3,               // 3× resolution for retina
  backgroundColor: '#000000',       // null = transparent
});