Skip to main content

styled-prose

GitHub Workflow Status PyPI - Downloads GitHub

Generate images and thumbnails based on bitmap transformations of rendered prose.

Documentation: https://styledprose.thearchitector.dev.

Tested support on Python 3.8, 3.9, 3.10, 3.11, and 3.12.

$ pdm add styled-prose
# or
$ pip install --user styled-prose

Example

The following stylesheet is a super simple example that overrides the default style's font size and family.

# stylesheet.toml

[[fonts]]
font_name = "EB Garamond"
from_google_fonts = true

[[styles]]
name = "default"
font_size = 14
font_name = "EB Garamond"

Using that stylesheet, and some basic prose, you can generate an image. The requested font family EB Garamond and its license are downloaded from Google Fonts and cached automatically; subsequent generations use those cached fonts.

from PIL import Image
from styled_prose import StyledProseGenerator

text: str = """
This is normal.

<i>This is italicized.</i>

<b>This is bold.</b>

<i><b>This is bold and italicized.</b></i>

<u>This is underlined.</u>

<strike>This is struck from the record.</strike>
"""
random.seed(771999)

generator: StyledProseGenerator = StyledProseGenerator("stylesheet.toml")
img: Image.Image = generator.create_jpg(
    text,
    angle=-2.5, # optional; an angle by which to rotate the image
    thumbnail=(210, 210), # optional; the dimensions of a random thumbnail
)

img.save("prose.jpg", quality=95)

This above code produces the following image:

example rendering

Metadata

Release files for styled-prose 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for styled-prose 1.0.0
File Size Uploaded Provenance Actions
styled_prose-1.0.0.tar.gz 15.1 kB Without provenance Details for styled_prose-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for styled-prose 1.0.0
File Interpreter ABI Platform Actions
styled_prose-1.0.0-py3-none-any.whl Python 3 none any Details for styled_prose-1.0.0-py3-none-any.whl

Total release size: 28.9 kB

Release files / styled_prose-1.0.0.tar.gz

Download URL styled_prose-1.0.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
360531d3e3ed8cae20b495fadf2e13c4d74e04b485881ed30ec01a05db7068b9
BLAKE2b-256 checksum
How to use checksums
6ea74d0e340e66830fbbf89f744de10673681187b22210becbb8c731c605dff4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.11.1 CPython/3.11.2

Release files / styled_prose-1.0.0-py3-none-any.whl

Download URL styled_prose-1.0.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
adc090e27dd531a8990550236fc6a2e08e72be2e6180bd2c171c4e72c2a555f0
BLAKE2b-256 checksum
How to use checksums
7607e72c575cf48552c8f333a0b9f5f8a1e2f4645e5ef4c716ac12bff6da9a94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.11.1 CPython/3.11.2

Security for styled-prose 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page