https://github.com/mnh-stack/svg-to-png-converter
SVG to PNG Converter - A Python script for converting SVG images to high-quality PNG using CairoSVG. Supports custom resolutions, 300 DPI print quality, and automatic directory handling.
https://github.com/mnh-stack/svg-to-png-converter
automation cairosvg dpi300 graphics high-resolution image-conversion png python svg
Last synced: about 2 months ago
JSON representation
SVG to PNG Converter - A Python script for converting SVG images to high-quality PNG using CairoSVG. Supports custom resolutions, 300 DPI print quality, and automatic directory handling.
- Host: GitHub
- URL: https://github.com/mnh-stack/svg-to-png-converter
- Owner: mnh-stack
- Created: 2025-03-21T18:31:49.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-21T18:51:29.000Z (about 2 months ago)
- Last Synced: 2025-03-21T22:31:47.609Z (about 2 months ago)
- Topics: automation, cairosvg, dpi300, graphics, high-resolution, image-conversion, png, python, svg
- Language: Python
- Homepage: https://www.svgviewer.dev/
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# svg-to-png-converter
A lightweight and efficient Python script for converting SVG files to PNG with high resolution using the CairoSVG library. Ideal for graphic designers, developers, and automation tasks.
## 🚀 Features
- Converts **SVG to PNG** with high resolution
- Supports **custom output dimensions (width & height)**
- Ensures **300 DPI quality for printing**
- Automatically **creates output directories** if missing
- Handles **file existence checks** and errors gracefully## 🛠 Installation & Setup
### 1⃣ Install Python (if not already installed)
Ensure you have Python 3.6+ installed. Check with:
```bash
python --version
```### 2⃣ Install Required Dependencies
Run the following command to install necessary libraries:
```bash
pip install cairosvg
```If you also need **PNG to SVG** conversion, install:
```bash
pip install png2svg
```### 3⃣ Clone the Repository
```bash
git clone https://github.com/yourusername/svg-to-png-converter.git
cd svg-to-png-converter
```### 4⃣ Run the Script
Place your SVG file in the `images/` folder and update the script with the correct file name. Then, run:
```bash
python svg_to_png_converter.py
```## 🖼️ Usage Example
1. Place an **SVG file** (`input_image.svg`) in the `images/` directory.
2. Update the script with your input/output file names.
3. Run the script to get a **high-quality PNG output**.## ⚙️ Converting PNG to SVG (Optional)
If you want to convert **PNG back to SVG**, use `png2svg`:
```python
from png2svg import png2svgpng2svg("images/input.png", "images/output.svg")
```## 📝 License
This project is licensed under the **MIT License**. Feel free to use and modify it.---