thorvg-python
A ctypes API for thorvg, with additional functions for getting Pillow Image.
The functions mostly follow thorvg/src/bindings/capi/thorvg_capi.h
Documentations: https://thorvg-python.readthedocs.io/en/latest/
Table of contents
Installing
Note that thorvg is included in the wheel package, you need not install libthorvg. Version bundled is the version available on Conan (Currently 1.0.4)
To install, run the following:
pip3 install thorvg-python
Pillow is optional dependency. It is required for SwCanvas.get_pillow(). To also install Pillow, run:
pip3 install thorvg-python[full]
Examples
Drawing and getting pillow image
import thorvg_python as tvg
engine = tvg.Engine(threads=4)
canvas = tvg.SwCanvas(engine)
canvas.set_target(512, 256) # w, h
rect = tvg.Shape(engine)
rect.append_rect(10, 10, 64, 64, 10, 10, True) # x, y, w, h, rx, ry, clockwise
rect.set_fill_color(32, 64, 128, 100) # r, g, b, a
canvas.add(rect)
canvas.update()
canvas.draw(True)
canvas.sync()
im = canvas.get_pillow()
im.save("test.png")
canvas.destroy()
engine.term()
Rendering lottie animation
import thorvg_python as tvg
from PIL import Image
engine = tvg.Engine(threads=4)
canvas = tvg.SwCanvas(engine)
canvas.set_target(512, 512) # w, h
animation = tvg.LottieAnimation(engine)
picture = animation.get_picture()
picture.load("tests/test.json")
picture.set_size(512, 512)
canvas.push(picture)
ims: list[Image.Image] = []
result, total_frame = animation.get_total_frame()
result, duration = animation.get_duration()
frame_duration = duration / total_frame
# fps = total_frame / duration
for i in range(int(total_frame)):
animation.set_frame(i)
canvas.update()
canvas.draw(True)
canvas.sync()
im = canvas.get_pillow()
ims.append(im)
ims[0].save("test.apng", save_all=True, append_images=ims[1:], duration=frame_duration * 1000)
Building from source
To build wheel, run the following:
git clone --recursive https://github.com/laggykiller/thorvg-python.git
cd thorvg-python
# To build wheel
python3 -m build .
# To install directly
pip3 install .
Development
To run tests:
pip install pytest
pytest
To lint:
pip install ruff mypy isort
mypy
isort .
ruff check
ruff format
Credits
- thorvg library: https://github.com/thorvg/thorvg
Metadata
Release files for thorvg-python 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| thorvg_python-1.1.3.tar.gz | 78.2 kB | Details |
Built distributions (wheels)
Total release size: 13.4 MB
Release files / thorvg_python-1.1.3.tar.gz
| Download URL | thorvg_python-1.1.3.tar.gz |
|---|---|
| Size | 78.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d1c0dcacc58208fb5001390944c4547299b46e6fb50b147363a40f678fbc620
|
|
BLAKE2b-256 checksum How to use checksums |
f75ea421ce26828cf04bd9a7862ff7fb0011a6bb19ffcdf768e31c392338184c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-win_arm64.whl
| Download URL | thorvg_python-1.1.3-py3-none-win_arm64.whl |
|---|---|
| Size | 855.7 kB |
| Tags | Python 3 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
4eba0ebb9f7529df7a31735716b6ff4c8e2126ec8942ae0f7aca4f3ce45294d7
|
|
BLAKE2b-256 checksum How to use checksums |
0be2e7bfa56233ebf01d01b2479d2c5adbeda96e8fc50d7f4cbb78fe3a9faaf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-win_amd64.whl
| Download URL | thorvg_python-1.1.3-py3-none-win_amd64.whl |
|---|---|
| Size | 969.1 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
305671f651d2e455d241c8704636f2061be86cdb80a6743cf6d7dce6bcca1c5a
|
|
BLAKE2b-256 checksum How to use checksums |
3d9f99902c58bda2082dea9687fe0aa75992429a9adbe2e5d82a729859641016
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-win32.whl
| Download URL | thorvg_python-1.1.3-py3-none-win32.whl |
|---|---|
| Size | 853.6 kB |
| Tags | Python 3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
2794128d3ec6c4e90f969d83b3f97a7a33e36ab794ba6e6c86710d86400e884e
|
|
BLAKE2b-256 checksum How to use checksums |
4c21e0db08c2d299b15120d9d61063ec1f3c1d8e2f195316df532ac833489c14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | thorvg_python-1.1.3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
0c2efd705bf7badd08b8f6e60696cb87fe908c9a04aa3b0352430aead00db33a
|
|
BLAKE2b-256 checksum How to use checksums |
b16eed45f8cf23c6edc62865053141d0c8f16f5cad9b3aaa74fa7a8528355ed4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-manylinux2014_s390x.manylinux_2_17_s390x.whl
| Download URL | thorvg_python-1.1.3-py3-none-manylinux2014_s390x.manylinux_2_17_s390x.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Linux glibc 2.17+ IBM System/390x Python 3 |
|
SHA-256 checksum How to use checksums |
fad03d766a4e17f8ba544dfe78a99a12e059b9cc5ff515b6a40eef2c7a5024c3
|
|
BLAKE2b-256 checksum How to use checksums |
6e88b7b32b2fbdf6d99c23cd73d5c16317629ed23d7c0a7ca585352be448044d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl
| Download URL | thorvg_python-1.1.3-py3-none-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Linux glibc 2.17+ PowerPC 64-le Python 3 |
|
SHA-256 checksum How to use checksums |
bafc7bd3747c89de60926ce1e8a4ade2efe2ac98f4edc134b0974d8d5fb98ce5
|
|
BLAKE2b-256 checksum How to use checksums |
0aafb2b006977a8bfe123af986dc291edc0df654b5e3337047eb6448648b2c6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-manylinux2014_i686.manylinux_2_17_i686.whl
| Download URL | thorvg_python-1.1.3-py3-none-manylinux2014_i686.manylinux_2_17_i686.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Linux glibc 2.17+ x86-32 Python 3 |
|
SHA-256 checksum How to use checksums |
6fffadda3a391044d3435cf14a446c78b3e0acc7fc4a4c1e88b4ff76207dca95
|
|
BLAKE2b-256 checksum How to use checksums |
d318e98658d9fce37a9e2c040a7dc0b051652510afa0ed7d201681f26d9fdd7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | thorvg_python-1.1.3-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
3e8baf4df97be90c449bda9eff9b85749f32034abaa046fb0ad5a13f3e1eba88
|
|
BLAKE2b-256 checksum How to use checksums |
ff197386a857588ebabe8d3eee8b52a1e59ad6f12ece0b2728f5e6e949214cd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-macosx_11_0_arm64.whl
| Download URL | thorvg_python-1.1.3-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
340fc8862e87e6071a26ae9d6d5e0e8acbc9aa8c2f39a038095f79d5cae60dbf
|
|
BLAKE2b-256 checksum How to use checksums |
382b22418f0e626c8d585cc113176073a8e51b52979625aaff8bdc2c35073d0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-macosx_10_9_x86_64.whl
| Download URL | thorvg_python-1.1.3-py3-none-macosx_10_9_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
56adc0159e331ce5879760d4606be0e25da74387240207a48375b9b757d81b5a
|
|
BLAKE2b-256 checksum How to use checksums |
346ca4d8e611ce8ad88878d241f08c216cbd944f7f953a744fbb96c3aa0fdd5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / thorvg_python-1.1.3-py3-none-macosx_10_9_universal2.whl
| Download URL | thorvg_python-1.1.3-py3-none-macosx_10_9_universal2.whl |
|---|---|
| Size | 2.1 MB |
| Tags | Python 3 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
f38141f14410c0991b8ac08db74850c6baf31a1ec45870ed74d65fdd6e02ac43
|
|
BLAKE2b-256 checksum How to use checksums |
1ed134b044fe29d49b47f9460fbe6715bf23009c5bf3632c6a104b5df8584f57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|