Metadata-Version: 2.4
Name: pylunasvg
Version: 0.1.2
Summary: Bindings for lunasvg
Home-page: https://github.com/erentknn/pylunasvg
Author: Eren Tekin
Author-email: erntkn4@gmail.com
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: summary

# pylunasvg - Python bindings for lunasvg

[![Build](https://github.com/erentknn/pylunasvg/actions/workflows/build_wheels.yml/badge.svg)](https://github.com/erentknn/pylunasvg/actions/workflows/build_wheels.yml)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pylunasvg.svg)](https://pypi.org/project/pylunasvg/)


Pylunasvg is a simple wrapper around [lunasvg](https://github.com/sammycage/lunasvg) that uses [pybind11](https://github.com/pybind/pybind11) to create python bindings. All public API of the lunasvg is available in Python.

Example usage is below, if you have any questions or problems, feel free to open an issue!

## Usage Example

```python
import pylunasvg as pl
import numpy as np

document = pl.Document.loadFromFile("FSL_Micelle.svg")
bitmap = document.renderToBitmap()
bitmap.convertToRGBA()

arr = np.array(bitmap, copy=False)
# Do something useful
```

## Convert SVG to PNG

To convert an SVG file to PNG (Unless otherwise specified, output is saved to same directory as SVG file), use the following command:

```bash
pylunasvg --svg FSL_Micelle.svg
pylunasvg --svg in.svg -W 512 -H 512       # explicit output size
pylunasvg --svg in.svg -s 2.0 -o out.png   # 2x scale, custom output path
```

## Install

```Python
pip install pylunasvg
```

## Build From Source

1-) Clone this repo with `--recursive` flag. This is needed because project uses lunasvg and pybind11 as git submodules.

2-) Run `pip install .` inside repo directory. (Make sure you are on the right conda environment.) This command will build lunasvg and then build pylunasvg. After this is over you can try the example above. If you get any errors, please submit an issue.
