file-converter
Scannednpx machina-cli add skill aiskillstore/marketplace/file-converter --openclawFile Converter
Overview
Convert files between formats across three categories: documents, data files, and images. Generate Python code dynamically for each conversion request, selecting appropriate libraries and handling edge cases.
Conversion Categories
Documents
| From | To | Recommended Library |
|---|---|---|
| Markdown | HTML | markdown or mistune |
| HTML | Markdown | markdownify or html2text |
| HTML | weasyprint or pdfkit (requires wkhtmltopdf) | |
| Text | pypdf or pdfplumber | |
| DOCX | Markdown | mammoth |
| DOCX | docx2pdf (Windows/macOS) or LibreOffice CLI | |
| Markdown | Convert via HTML first, then to PDF |
Data Files
| From | To | Recommended Library |
|---|---|---|
| JSON | YAML | pyyaml |
| YAML | JSON | pyyaml |
| JSON | CSV | pandas or stdlib csv + json |
| CSV | JSON | pandas or stdlib csv + json |
| JSON | TOML | tomli/tomllib (read) + tomli-w (write) |
| XML | JSON | xmltodict |
| JSON | XML | dicttoxml or xmltodict.unparse |
Images
| From | To | Recommended Library |
|---|---|---|
| PNG/JPG/WebP/GIF | Any raster | Pillow (PIL) |
| SVG | PNG/JPG | cairosvg or svglib + reportlab |
| PNG | SVG | potrace (CLI) for tracing, limited fidelity |
Workflow
- Identify source format (from file extension or user statement)
- Identify target format
- Check
references/for format-specific guidance - Generate conversion code using recommended library
- Handle edge cases (encoding, transparency, nested structures)
- Execute conversion and report results
Quick Patterns
Data: JSON to YAML
import json
import yaml
with open("input.json") as f:
data = json.load(f)
with open("output.yaml", "w") as f:
yaml.dump(data, f, default_flow_style=False, allow_unicode=True)
Data: CSV to JSON
import csv
import json
with open("input.csv") as f:
reader = csv.DictReader(f)
data = list(reader)
with open("output.json", "w") as f:
json.dump(data, f, indent=2)
Document: Markdown to HTML
import markdown
with open("input.md") as f:
md_content = f.read()
html = markdown.markdown(md_content, extensions=["tables", "fenced_code"])
with open("output.html", "w") as f:
f.write(html)
Image: PNG to WebP
from PIL import Image
img = Image.open("input.png")
img.save("output.webp", "WEBP", quality=85)
Image: SVG to PNG
import cairosvg
cairosvg.svg2png(url="input.svg", write_to="output.png", scale=2)
Resources
Detailed guidance for complex conversions is in references/:
references/document-conversions.md- PDF handling, encoding issues, styling preservationreferences/data-conversions.md- Schema handling, type coercion, nested structuresreferences/image-conversions.md- Quality settings, transparency, color profiles
Consult these references when handling edge cases or when the user has specific quality/fidelity requirements.
Source
git clone https://github.com/aiskillstore/marketplace/blob/main/skills/89jobrien/file-converter/SKILL.mdView on GitHub Overview
File Converter handles conversions across documents, data files, and images. It dynamically generates Python code for each request, selecting the right libraries (markdown, weasyprint, pypdf, mammoth, pyyaml, Pillow, cairosvg, etc.) and addressing edge cases like encoding and fidelity.
How This Skill Works
The tool first identifies the source and target formats from the file or user input, then consults format guidance in references/ to select a suitable library. It emits Python code tailored to the specific conversion and executes it, handling edge cases such as encoding, metadata, and nested structures before producing the output.
When to Use It
- Convert Markdown to HTML for web pages
- Convert JSON to YAML for config files
- Convert DOCX to PDF for distribution
- Convert PNG/JPEG/WebP to another raster format for compatibility
- Convert CSV to JSON for data interchange
Quick Start
- Step 1: Provide a source file and a target format (e.g., input.json -> YAML).
- Step 2: The system analyzes formats and selects the recommended library.
- Step 3: Run the generated Python script to perform the conversion and inspect the output.
Best Practices
- Always identify source and target formats by extension or explicit user intent
- Check references/ for format-specific guidance and edge cases
- Prefer using libraries that preserve encoding and Unicode correctly
- Test the output and validate with basic round-trips when possible
- Document the generated code and library versions used
Example Use Cases
- JSON to YAML using PyYAML
- CSV to JSON using pandas or csv+json stdlib
- Markdown to HTML using markdown or mistune
- HTML to PDF using WeasyPrint or wkhtmltopdf
- PNG to WebP using Pillow