agentleFS
danielrosehilldanielrosehill/Claude-Image-Production-Plugin/skills/svg-to-raster/SKILL.md

svg-to-raster

Skill21 starsChanged 8 days agoMITView on GitHub

Use when the user wants to rasterize SVG files — convert SVG to PNG, PDF, or PostScript at a chosen resolution. Wraps CairoSVG (Python, in the plugin venv). Single file or batch. Companion to `vectorize` (other direction).

  • Installs packages

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not use this skill when:

    line 16
  2. Very specific:

    Verify cairosvg is importable in the venv:

    line 36
  3. Very specific:

    If missing → point at install-deps.

    line 42
  4. Very specific:

    If you need true SVG editing or advanced filter support, look at Inkscape CLI (inkscape --export-type=png).

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SVG to Raster

Rasterize SVG files to PNG / PDF / PS via CairoSVG. Runs from the plugin's uv venv — no system Python pollution.

When to use

  • Convert logo / icon / diagram SVGs to PNG for use in slides, social, or pipelines that don't accept SVG.
  • Render an SVG at multiple resolutions (e.g. 1×, 2×, 3× for app assets).
  • Bake an SVG into a PDF for print or archival.

Do not use this skill when:

  • Source is already raster — wrong direction; use vectorize instead.
  • You need to edit the SVG — CairoSVG is render-only.
  • The SVG uses advanced filters / unsupported CSS — CairoSVG covers SVG 1.1 well but newer features may not render. Inspect output and warn the user.

Inputs

  1. Input — SVG file or directory. Required.
  2. Format — png (default), pdf, ps.
  3. Output dir — default: <input-dir>/<format>/. Never overwrites originals.
  4. Scale — multiplier on the SVG's intrinsic size. Default 1.0. Use 2.0, 3.0 for hi-DPI.
  5. Width / Height — explicit pixel dimensions (overrides scale). Pass one to preserve aspect; both to force.
  6. DPI — for PDF/PS output. Default 96.
  7. Background — default transparent. Pass a CSS colour (#ffffff, white) for solid fill.
  8. Recursive — --recursive for directory descent.

Procedure

  1. Resolve venv: VENV_DIR="${CLAUDE_USER_DATA:-${XDG_DATA_HOME:-$HOME/.local/share}/claude-plugins}/image-production/venv".
  2. Verify cairosvg is importable in the venv:

    "$VENV_DIR/bin/python" -c "import cairosvg" 2>&1

    If missing → point at install-deps. If it imports but raises a libcairo error, surface the system-lib install command (sudo apt install libcairo2 / brew install cairo).

  3. Enumerate *.svg inputs (case-insensitive). Skip non-SVG with note.
  4. For each file, call CairoSVG via Python one-liner (keeps the skill self-contained — no helper script needed):

    "$VENV_DIR/bin/python" -c "
    import cairosvg, sys
    kwargs = {'url': sys.argv[1], 'write_to': sys.argv[2]}
    # Inject scale / dimensions / dpi / background as appropriate
    cairosvg.svg2png(**kwargs)  # or svg2pdf / svg2ps
    " "<input.svg>" "<output.png>"

    Function map: png → svg2png, pdf → svg2pdf, ps → svg2ps.

    Optional kwargs: scale=<float>, output_width=<int>, output_height=<int>, dpi=<int>, background_color="<css>".

  5. Track file sizes and any render warnings (CairoSVG prints to stderr for unsupported features).

Output

  • Rasterized files at <output-dir>/.
  • Summary:
    • Files processed / failed.
    • Per-file: source dimensions → output dimensions, output size.
    • Any render warnings (unsupported SVG features).

Notes

  • CairoSVG is LGPL-3.0; using it as a CLI dependency is fine, no licence contagion.
  • For multi-resolution batch (e.g. app icon set), call this skill multiple times with different --scale values, or wrap in a small loop.
  • If you need true SVG editing or advanced filter support, look at Inkscape CLI (inkscape --export-type=png). CairoSVG is the lighter-weight pure-Python option.
  • Animated SVG (SMIL) is not supported — CairoSVG renders the initial frame only.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.