-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9661f9
commit 9c67fcd
Showing
7 changed files
with
118 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Contributing | ||
============ | ||
|
||
Thank you taking interest in this project. | ||
|
||
|
||
Goals | ||
----- | ||
|
||
My goal for this project is: | ||
|
||
* To enable all the features available in `resvg` but don't write to the disk, everything must be done in memory. | ||
* Use the bare minimum amount of packages, in both python side and rust side | ||
|
||
Getting Started | ||
--------------- | ||
|
||
Pre-requisite packages: | ||
|
||
* Install `poetry <https://python-poetry.org/>`_ | ||
|
||
* Install `pipx <https://pipx.pypa.io/stable/installation/>`_ | ||
|
||
* Install `maturin <https://www.maturin.rs/tutorial>`_ | ||
|
||
|
||
Then do the modifications to the `lib.rs` file and add test in tests directory. | ||
|
||
1. Install **poetry** dependencies: | ||
|
||
.. code-block:: sh | ||
poetry install | ||
2. Activate **poetry** shell: | ||
|
||
.. code-block:: sh | ||
poetry shell | ||
3. Build with **maturin**: | ||
|
||
.. code-block:: sh | ||
maturin develop | ||
4. Run tests: | ||
|
||
|
||
.. code-block:: sh | ||
pytest . | ||
If all tests pass, please send a Pull Request to the main repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Resvg Module | ||
============ | ||
|
||
.. currentmodule:: resvg_py.svg_to_base64 | ||
|
||
|
||
.. function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Usage | ||
===== | ||
|
||
|
||
The module takes in **utf-8** encoded `svg_string` and returns `base64` encoded **PNG** string. | ||
|
||
|
||
Lets say our svg looks like this : | ||
|
||
.. raw:: html | ||
|
||
<center> | ||
<svg width="300" height="130" xmlns="http://www.w3.org/2000/svg"> | ||
<rect width="200" height="100" x="10" y="10" rx="20" ry="20" fill="blue" /> | ||
</svg> | ||
</center> | ||
|
||
|
||
We can convert it to `PNG` by: | ||
|
||
|
||
.. code-block:: python | ||
import resvg_py | ||
svg_string = """ | ||
<svg width="300" height="130" xmlns="http://www.w3.org/2000/svg"> | ||
<rect width="200" height="100" x="10" y="10" rx="20" ry="20" fill="blue" /> | ||
</svg> | ||
""" | ||
print(resvg_py.svg_to_base64(svg_string)) | ||
This should return the following **PNG** image: | ||
|
||
.. raw:: html | ||
|
||
<center> | ||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACCCAYAAAD8HPVfAAAIBElEQVR4Ae3gAZAkSZIkSRKLqpm7R0REZmZmVlVVVVV3d3d3d/fMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMdHd3d3dXV1VVVVVmZkZGRIS7m5kKz0xmV3d1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