본문으로 건너뛰기
cccskills
무료GitHub에 공개

snapdom

Build image export features for HTML elements with snapDOM. The skill covers SVG, PNG, JPG, and WebP output, preserving styles and fonts, adjusting dimensions, excluding elements, and troubleshooting missing resources.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

snapDOM is a fast, accurate DOM-to-image capture tool that converts HTML elements into scalable SVG images. Use for capturing HTML elements, converting DOM to images (SVG, PNG, JPG, WebP), preserving styles, fonts, and pseudo-elements.

설치 방법 보기

이럴 때 유용합니다

  • Adding image downloads for HTML elements
  • Exporting charts and graphics as SVG
  • Creating images with specified dimensions
  • Troubleshooting missing fonts or images

포함된 파일(3)

  • SKILL.md7.5 KB
  • references/index.md90 B
  • references/other.md883 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

SnapDOM Skill

Fast, dependency-free DOM-to-image capture library for converting HTML elements into scalable SVG or raster image formats.

When to Use This Skill

Use SnapDOM when you need to:

  • Convert HTML elements to images (SVG, PNG, JPG, WebP)
  • Capture styled DOM with pseudo-elements and shadows
  • Export elements with embedded fonts and icons
  • Create screenshots with custom dimensions or scaling
  • Handle CORS-blocked resources using proxy fallback
  • Implement custom rendering pipelines with plugins
  • Optimize performance on large or complex elements

Key Features

Universal Export Options

  • SVG - Scalable vector format, embeds all styles
  • PNG, JPG, WebP - Raster formats with configurable quality
  • Canvas - Get raw Canvas element for further processing
  • Blob - Raw binary data for custom handling

Performance

  • Ultra-fast capture (1.6ms for small elements, ~171ms for 4000×2000)
  • No dependencies - Uses standard Web APIs only
  • Outperforms html2canvas by 10-40x on complex elements

Style Support

  • Embedded fonts (including icon fonts)
  • CSS pseudo-elements (::before, ::after)
  • CSS counters
  • CSS line-clamp
  • Transform and shadow effects
  • Shadow DOM content

Advanced Capabilities

  • Same-origin iframe support
  • CORS proxy fallback for blocked assets
  • Plugin system for custom transformations
  • Straighten transforms (remove rotate/translate)
  • Selective element exclusion
  • Tight bounding box calculation

Installation

NPM/Yarn

npm install @zumer/snapdom
# or
yarn add @zumer/snapdom

CDN (ES Module)

<script type="module">
  import { snapdom } from "https://unpkg.com/@zumer/snapdom/dist/snapdom.mjs";
</script>

CDN (UMD)

<script src="https://unpkg.com/@zumer/snapdom/dist/snapdom.umd.js"></script>

Quick Start Examples

Basic Reusable Capture

// Create reusable capture object
const result = await snapdom(document.querySelector('#target'));

// Export to different formats
const png = await result.toPng();
const jpg = await result.toJpg();
const svg = await result.toSvg();
const canvas = await result.toCanvas();
const blob = await result.toBlob();

// Use the result
document.body.appendChild(png);

One-Step Export

// Direct export without intermediate object
const png = await snapdom.toPng(document.querySelector('#target'));
const svg = await snapdom.toSvg(element);

Download Element

// Automatically download as file
await snapdom.download(element, 'screenshot.png');
await snapdom.download(element, 'image.svg');

With Options

const result = await snapdom(element, {
  scale: 2,                    // 2x resolution
  width: 800,                  // Custom width
  height: 600,                 // Custom height
  embedFonts: true,            // Include @font-face
  exclude: '.no-capture',      // Hide elements
  useProxy: true,              // Enable CORS proxy
  straighten: true,            // Remove transforms
  noShadows: false             // Keep shadows
});

const png = await result.toPng({ quality: 0.95 });

Essential Options Reference

OptionTypePurpose
scaleNumberScale output (e.g., 2 for 2x resolution)
widthNumberCustom output width in pixels
heightNumberCustom output height in pixels
embedFontsBooleanInclude non-icon @font-face rules
useProxyString|BooleanEnable CORS proxy (URL or true for default)
excludeStringCSS selector for elements to hide
straightenBooleanRemove translate/rotate transforms
noShadowsBooleanStrip shadow effects

Common Patterns

Responsive Screenshots

// Capture at different scales
const mobile = await snapdom.toPng(element, { scale: 1 });
const tablet = await snapdom.toPng(element, { scale: 1.5 });
const desktop = await snapdom.toPng(element, { scale: 2 });

Exclude Elements

// Hide specific elements from capture
const png = await snapdom.toPng(element, {
  exclude: '.controls, .watermark, [data-no-capture]'
});

Fixed Dimensions

// Capture with specific size
const result = await snapdom(element, {
  width: 1200,
  height: 630  // Standard social media size
});

CORS Handling

// Fallback for CORS-blocked resources
const png = await snapdom.toPng(element, {
  useProxy: 'https://cors.example.com/?' // Custom proxy
});

Plugin System (Beta)

// Extend with custom exporters
snapdom.plugins([pluginFactory, { colorOverlay: true }]);

// Hook into lifecycle
defineExports(context) {
  return {
    pdf: async (ctx, opts) => { /* generate PDF */ }
  };
}

// Lifecycle hooks available:
// beforeSnap → beforeClone → afterClone →
// beforeRender → beforeExport → afterExport

Performance Comparison

SnapDOM significantly outperforms html2canvas:

ScenarioSnapDOMhtml2canvasImprovement
Small (200×100)1.6ms68ms42x faster
Medium (800×600)12ms280ms23x faster
Large (4000×2000)171ms1,800ms10x faster

Development

Setup

git clone https://github.com/zumerlab/snapdom.git
cd snapdom
npm install

Build

npm run compile

Testing

npm test

Browser Support

  • Chrome/Edge 90+
  • Firefox 88+
  • Safari 14+
  • Mobile browsers (iOS Safari 14+, Chrome Mobile)

Resources

Documentation

scripts/

Add helper scripts here for automation, e.g.:

  • batch-screenshot.js - Capture multiple elements
  • pdf-export.js - Convert snapshots to PDF
  • compare-outputs.js - Compare SVG vs PNG quality

assets/

Add templates and examples:

  • HTML templates for common capture scenarios
  • CSS frameworks pre-configured with snapdom
  • Boilerplate projects integrating snapdom

Related Tools

Tips & Best Practices

  1. Performance: Use scale instead of width/height for better performance
  2. Fonts: Set embedFonts: true to ensure custom fonts appear correctly
  3. CORS Issues: Use useProxy: true if images fail to load
  4. Large Elements: Break into smaller chunks for complex pages
  5. Quality: For PNG/JPG, use quality: 0.95 for best quality
  6. SVG Vectors: Prefer SVG export for charts and graphics

Troubleshooting

Elements Not Rendering

  • Check if element has sufficient height/width
  • Verify CSS is fully loaded before capture
  • Try straighten: false if transforms are causing issues

Missing Fonts

  • Set embedFonts: true
  • Ensure fonts are loaded before calling snapdom
  • Check browser console for font loading errors

CORS Issues

  • Enable useProxy: true
  • Use custom proxy URL if default fails
  • Check if resources are from same origin

Performance Issues

  • Reduce scale value
  • Use noShadows: true to skip shadow rendering
  • Consider splitting large captures into smaller sections

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

ccxt

무료

Build cryptocurrency exchange integrations with CCXT in JavaScript, Python, or PHP. The skill helps retrieve market data, manage orders, automate trading workflows, check exchange-specific capabilities, and investigate API errors using reproducible examples and logs.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Retrieve market data from multiple cryptocurrency exchanges
  • Implement order management and trading automation
  • Check support for stop-loss and take-profit orders
2025Emma/vibe-coding-cn2.3만2025년 12월 17일 업데이트

Learn Claude Code workflows through a Chinese-language guide covering tool use, large-file analysis, task tracking, and troubleshooting. It also explains MCP, a protocol for connecting external systems, alongside development and review patterns.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Learn tool use and development workflows
  • Analyze large files in manageable sections
  • Study MCP connections to external systems
2025Emma/vibe-coding-cn2.3만2025년 12월 17일 업데이트

Develop applications with the Claude API using examples from Anthropic's official cookbooks. Explore document summarization, image analysis, document retrieval, external tool calls, and prompt caching through practical Python code and implementation guidance.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Learning basic Claude API integration
  • Building an assistant that searches documents
  • Extracting text and information from images
2025Emma/vibe-coding-cn2.3만2025년 12월 17일 업데이트

Turn documentation, code, and specifications into reusable Agent Skills. Define when each skill should activate, organize supporting references, add reproducible examples, and check new or existing skills with templates, a checklist, and a validator.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Creating an Agent Skill from documentation and code
  • Reorganizing an overly long SKILL.md
  • Clarifying skill activation conditions and boundaries
2025Emma/vibe-coding-cn2.3만2025년 12월 17일 업데이트

coingecko

무료

Use CoinGecko API documentation to build cryptocurrency price trackers and market data integrations. The skill supports implementation and debugging for access to prices, market capitalization, trading volume, and historical data.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Building a cryptocurrency price tracker
  • Integrating market capitalization and trading volume data
  • Exploring how to retrieve historical prices
2025Emma/vibe-coding-cn2.3만2025년 12월 17일 업데이트

Build Python applications that collect live cryptocurrency prices, trades, and order books with Cryptofeed. Covers consistent data formats across exchanges, price comparisons, and writing incoming data to storage systems for monitoring and analysis.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Monitoring prices across cryptocurrency exchanges
  • Analyzing order book depth
  • Analyzing executed trade flows
2025Emma/vibe-coding-cn2.3만2025년 12월 17일 업데이트

2025Emma의 스킬 모두 보기

이 스킬의 문제 신고