Files
branding/README.md
2026-03-30 00:26:18 +00:00

46 lines
1.2 KiB
Markdown
Executable File

# SVG Processor
This Python script processes an SVG file by removing specified elements, embedding fonts, and exporting to multiple formats.
## Features
- Remove SVG elements based on IDs specified in a JSON file
- Embed fonts from external files into the SVG as base64
- Optimize the SVG using scour
- Export to optimized SVG, PNG, JPEG, and thumbnail JPEG
## Requirements
- Python 3.9+
- Libraries: lxml, cairosvg, scour
## Docker Usage
Build the Docker image:
```bash
docker build -t svg-processor .
```
Run the container:
```bash
docker run -v /path/to/input:/input -v /path/to/output:/output svg-processor python svg_processor.py /input/input.svg /input/config.json /output
```
Replace `/path/to/input` and `/path/to/output` with actual paths.
## JSON Configuration Format
See `sample_config.json` for an example.
- `remove`: Array of element IDs to remove
- `fonts`: Object mapping font-family names to font file paths
- `size`: Override the size - useful when the size of the new image cannot be automatically calulated
## Output
- `optimized.svg`: Optimized SVG with embedded fonts
- `output.png`: PNG version
- `output.jpg`: JPEG version
- `thumbnail.jpg`: Thumbnail JPEG (128x128 max)