*Unofficial* client for the Rtex API server
Project description
Async Python Client to The RTEX API Server
Installation
pip install rtex
Usage
The API surface of Rtex is spartan so this is basically the whole thing.
import asyncio
from rtex.client import AsyncRtexClient
async def amain():
async with AsyncRtexClient() as rtex:
res = rtex.create_render("\(x^2 + x - 1\)")
if res.status == "success":
with open("equation.png") as output_fd:
await res.save_render(
res.filename,
output_fd
)
def main():
asyncio.run(amain())
if __name__ == "__main__":
main()
No Thoughts, Just Render
async def amain():
async with AsyncRtexClient() as rtex:
buf = await rtex.render_math("e^x + 1")
# `buf` now contains the bytes of the PNG
Do I look like I know what a Jay-Peg is?
async def amain():
async with AsyncRtexClient() as rtex:
# The render methods accept a format parameter.
# Supported values are "png", "jpg" and "pdf"
buf = await rtex.render_math("e^x + 1", format="jpg")
Self-Hoster
Set the environment variable RTEX_API_HOST
or do the following.
async def amain():
async with AsyncRtexClient(api_host="https://myserver.ru") as rtex:
buf = await rtex.render_math("e^x + 1")
I Can Tell By The Pixels
quality
in Rtex speak is an abstract notion of compression for the given
format where 100
is the least compressed and 0
is the most. At the time of
writing the default is 85
.
density
in Rtex speak is how much to sample the rendered PDF when generating
an image. This has no effect on the "pdf"
format. At the time of writing the
default is 200
.
async def amain():
async with AsyncRtexClient(api_host="https://myserver.ru") as rtex:
needs_more_jpeg = await rtex.render_math(
"e^x + 1",
density=50,
quality=1
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rtex-0.0.5.tar.gz
(6.9 kB
view details)
Built Distribution
rtex-0.0.5-py3-none-any.whl
(5.5 kB
view details)
File details
Details for the file rtex-0.0.5.tar.gz
.
File metadata
- Download URL: rtex-0.0.5.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 116a4aba1295e9951689c290f761ca45ab89a68ff286ab7dba160f0d7ef9013c |
|
MD5 | a95fb4b092ee21475085480b3671b594 |
|
BLAKE2b-256 | 127f7d70e139a28883aa8e00d43cba9756f623eadb8b05099fa77a88623e2c2b |
File details
Details for the file rtex-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: rtex-0.0.5-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea4583e7da1f8cec8f92a08498304b7e86e043e83576d9aa05f5448c35bc4d79 |
|
MD5 | 49bf3279cde8e7bc1a59e2bd7b99f8cd |
|
BLAKE2b-256 | 2f0ea5f1e4eeef2c66a47770a99a664014869d180f42c86083818b7c1919b53a |