jpskill.com
🎨 デザイン コミュニティ

snapdom

snapDOMは、HTML要素を高品質なSVG画像に変換し、スタイルやフォント、擬似要素も保持したまま、様々な画像形式で出力できる、ウェブページの見た目を忠実に画像化するSkill。

📜 元の英語説明(参考)

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.

🇯🇵 日本人クリエイター向け解説

一言でいうと

snapDOMは、HTML要素を高品質なSVG画像に変換し、スタイルやフォント、擬似要素も保持したまま、様々な画像形式で出力できる、ウェブページの見た目を忠実に画像化するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o snapdom.zip https://jpskill.com/download/16685.zip && unzip -o snapdom.zip && rm snapdom.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/16685.zip -OutFile "$d\snapdom.zip"; Expand-Archive "$d\snapdom.zip" -DestinationPath $d -Force; ri "$d\snapdom.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して snapdom.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → snapdom フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
3

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

SnapDOM Skill

HTML要素をスケーラブルなSVGまたはラスター画像形式に変換するための、高速で依存関係のないDOM-to-imageキャプチャライブラリです。

このSkillを使用する場面

SnapDOMは、以下のような場合に利用できます。

  • HTML要素を画像に変換する(SVG、PNG、JPG、WebP)
  • スタイルが適用されたDOMを、疑似要素や影付きでキャプチャする
  • 埋め込みフォントとアイコンを持つ要素をエクスポートする
  • カスタムの寸法またはスケーリングでスクリーンショットを作成する
  • プロキシフォールバックを使用してCORSでブロックされたリソースを処理する
  • プラグインを使用してカスタムレンダリングパイプラインを実装する
  • 大きくて複雑な要素のパフォーマンスを最適化する

主な機能

ユニバーサルなエクスポートオプション

  • SVG - スケーラブルなベクター形式で、すべてのスタイルを埋め込みます
  • PNG, JPG, WebP - 設定可能な品質のラスター形式
  • Canvas - さらなる処理のために生の Canvas 要素を取得します
  • Blob - カスタム処理用の生のバイナリデータ

パフォーマンス

  • 超高速キャプチャ(小さな要素で1.6ms、4000×2000で〜171ms)
  • 依存関係なし - 標準のWeb APIのみを使用
  • 複雑な要素でhtml2canvasより10〜40倍高速

スタイルサポート

  • 埋め込みフォント(アイコンフォントを含む)
  • CSS疑似要素(::before、::after)
  • CSSカウンター
  • CSS line-clamp
  • Transformおよびshadowエフェクト
  • Shadow DOMコンテンツ

高度な機能

  • Same-origin iframeサポート
  • ブロックされたアセットに対するCORSプロキシフォールバック
  • カスタム変換用のプラグインシステム
  • Transformの直線化(rotate/translateの削除)
  • 選択的な要素の除外
  • 厳密なバウンディングボックスの計算

インストール

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>

クイックスタートの例

基本的な再利用可能なキャプチャ

// 再利用可能なキャプチャオブジェクトを作成
const result = await snapdom(document.querySelector('#target'));

// さまざまな形式にエクスポート
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();

// 結果を使用
document.body.appendChild(png);

ワンステップエクスポート

// 中間オブジェクトなしで直接エクスポート
const png = await snapdom.toPng(document.querySelector('#target'));
const svg = await snapdom.toSvg(element);

要素のダウンロード

// ファイルとして自動的にダウンロード
await snapdom.download(element, 'screenshot.png');
await snapdom.download(element, 'image.svg');

オプション付き

const result = await snapdom(element, {
  scale: 2,                    // 2倍の解像度
  width: 800,                  // カスタム幅
  height: 600,                 // カスタム高さ
  embedFonts: true,            // @font-faceを含める
  exclude: '.no-capture',      // 要素を非表示にする
  useProxy: true,              // CORSプロキシを有効にする
  straighten: true,            // Transformを削除する
  noShadows: false             // 影を保持する
});

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

必須オプションリファレンス

Option Type Purpose
scale Number 出力を拡大縮小します(例:2は2倍の解像度)
width Number ピクセル単位でのカスタム出力幅
height Number ピクセル単位でのカスタム出力高さ
embedFonts Boolean アイコン以外の @font-face ルールを含めます
useProxy String|Boolean CORSプロキシを有効にします(URLまたはデフォルトの場合はtrue)
exclude String 非表示にする要素のCSSセレクター
straighten Boolean translate/rotate transformを削除します
noShadows Boolean 影のエフェクトを取り除きます

一般的なパターン

レスポンシブなスクリーンショット

// さまざまなスケールでキャプチャ
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 });

要素の除外

// キャプチャから特定の要素を非表示にする
const png = await snapdom.toPng(element, {
  exclude: '.controls, .watermark, [data-no-capture]'
});

固定寸法

// 特定のサイズでキャプチャ
const result = await snapdom(element, {
  width: 1200,
  height: 630  // 標準的なソーシャルメディアのサイズ
});

CORS処理

// CORSでブロックされたリソースのフォールバック
const png = await snapdom.toPng(element, {
  useProxy: 'https://cors.example.com/?' // カスタムプロキシ
});

プラグインシステム(ベータ版)

// カスタムエクスポーターで拡張
snapdom.plugins([pluginFactory, { colorOverlay: true }]);

// ライフサイクルにフック
defineExports(context) {
  return {
    pdf: async (ctx, opts) => { /* generate PDF */ }
  };
}

// 利用可能なライフサイクルフック:
// beforeSnap → beforeClone → afterClone →
// beforeRender → beforeExport → afterExport

パフォーマンス比較

SnapDOMはhtml2canvasよりも大幅に優れています。

Scenario SnapDOM html2canvas Improvement
Small (200×100) 1.6ms 68ms 42x faster
Medium (800×600) 12ms 280ms 23x faster
Large (4000×2000) 171ms 1,800ms 10x faster

開発

セットアップ

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

ビルド

npm run compile

テスト

npm test

ブラウザのサポート

  • Chrome/Edge 90+
  • Firefox 88+
  • Safari 14+
  • モバイルブラウザ(iOS Safari 14+、Chrome Mobile)

リソース

ドキュメント

scripts/

自動化のためのヘルパースクリプトをここに追加します。例:

  • batch-screenshot.js - 複数の要素をキャプチャ
  • pdf-export.js - スナップショットをPDFに変換
  • compare-outputs.js - SVGとPNGの品質を比較

assets/

テンプレートと例を追加

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

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

Option Type Purpose
scale Number Scale output (e.g., 2 for 2x resolution)
width Number Custom output width in pixels
height Number Custom output height in pixels
embedFonts Boolean Include non-icon @font-face rules
useProxy String|Boolean Enable CORS proxy (URL or true for default)
exclude String CSS selector for elements to hide
straighten Boolean Remove translate/rotate transforms
noShadows Boolean Strip 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:

Scenario SnapDOM html2canvas Improvement
Small (200×100) 1.6ms 68ms 42x faster
Medium (800×600) 12ms 280ms 23x faster
Large (4000×2000) 171ms 1,800ms 10x 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

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。