svg-to-png

Convert standalone SVG files to PNG using cairosvg on the RCC Midway HPC cluster.

1|Updated Oct 25, 2020
One-click install
npx skills add https://github.com/bfairkun/dotfiles --skill svg-to-png-bfairkun
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: svg-to-png
Source: https://github.com/bfairkun/dotfiles/tree/main/agents/.agents/skills/svg-to-png
Command: npx skills add https://github.com/bfairkun/dotfiles --skill svg-to-png-bfairkun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires cairosvg.

What problem does it solve? The RCC Midway HPC cluster has no rsvg-convert, inkscape, or resvg, and its ImageMagick build has no working SVG delegate, so standard SVG-to-PNG conversion commands produce blank or garbage output. This Skill provides the one working rasterization path on Midway: cairosvg from a dedicated conda environment. ## Core Features & Use Cases - SVG Rasterization: Converts standalone .svg files to .png at 300 DPI using the cairosvg binary called by absolute path, with no environment activation required. - Flexible Sizing: Supports --dpi, --scale, and --output-width options to control output resolution and exact pixel dimensions. - Environment Recovery: Documents how to recreate the throwaway claude_svgrender conda env with mamba if it is ever missing. - Use Case: You have a hand-authored SVG figure for a wiki attachment and need a publication-quality PNG; run the documented cairosvg command and verify dimensions with ImageMagick identify. ## Quick Start Convert my figure.svg file to a 300 DPI PNG using the cairosvg binary from the claude_svgrender conda environment.

Frequently Asked Questions about svg-to-png

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert SVG to PNG on an HPC cluster without inkscape?▼

Use cairosvg, a Python-based SVG rasterizer that works without inkscape or rsvg-convert. On RCC Midway, call the binary directly at /project2/gilad/bjf79_project1/envs/claude_svgrender/bin/cairosvg with the input SVG, -o output flag, and --dpi 300.

Why does ImageMagick convert produce blank output for SVG files?▼

ImageMagick on Midway has no working SVG delegate, so its convert command produces blank or garbage output when reading SVG files. Use cairosvg instead for SVG rasterization; ImageMagick identify still works fine for checking output dimensions.

How do I control the resolution when converting SVG to PNG with cairosvg?▼

Pass --dpi 300 for publication-quality raster output, --scale 2 for twice the SVG's nominal pixel size, or --output-width N to set an exact pixel width. Verify the result with identify -format "%wx%h\n" on the output PNG.

Why is text missing or wrong in my cairosvg PNG output?▼

cairosvg renders text via cairo rather than matplotlib, so fonts referenced in the SVG must be available to cairo. Fix it by using Nimbus Sans, the Helvetica substitute available on Midway, or by exporting text as paths from the figure generator.

Should I use cairosvg for matplotlib-generated figures?▼

No. If a Python script generates the figure, call fig.savefig("out.png", dpi=300) directly with the Agg backend and skip external rasterizers entirely. cairosvg is only needed for standalone or hand-authored .svg files that must become PNG.