Generate an image for a text stencil
Project description
stencil-maker
Generate an image as a text stencil, with custom fonts, sizes and optionally flipping the image horizontally.
Installation
Get a instalable wheel from the releases page, once it downloads, install it with:
$ pip install stencil_maker-VERSION-py3-none-any.whl
$ # The VERSION might be different depending on the version downloaded
To install with the server mode enabled, include the [server]
extra feature when installing:
$ pip install 'stencil_maker-VERSION-py3-none-any.whl[server]'
From PyPI
Coming soon
Usage
Whenever a font is required as an option, you may pass either a path pointing to the font or the font basename, which the library will try to find in the system's font directories.
Command line
$ # The -h or --help flags provide information on usage
$ stencil-maker --help
...
$ # Basic usage requires the font name or font filename and a output filename
$ # Provide the text to draw via stdin
$ stencil-maker -f LiberationSans-Regular output.png
My text may be split
into multiple lines
This is not a haiku
$ stencil-maker --font font-dir/LiberationSans-Bold.ttf --flip --size 300 output2.png
This is a test
$
Server
This functionality will only be available if the package was installed with the server
feature enabled.
The server program requires the STENCIL_MAKER_FONT
environment variable to be defined, either in the program environment or a .env
file.
To run the server you can quickly use the stencil-server
command, which spins up a simple flask server running on localhost
port 5000
. For futher customizing the server options, provide the path to the server module to your WSGI server and configure it to your liking. For example using flask
as WSGI server and passing a few settings:
flask run --port 5001 --host 0.0.0.0 --app stencil_maker.server
Python library
This package provides a simple api to produce images. The main interface is the python stencil_maker.make_stencil()
function, which returns a regular Pillow Image
instance, which can be saved or processed further. For example:
from stencil_maker import make_stencil
stencil = make_stencil("This is a test", "LiberationMono-Regular", 300)
stencil.save("my-stencil.png")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file stencil_maker-0.1.0.tar.gz
.
File metadata
- Download URL: stencil_maker-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb9f0c094333fc754f37539b9d702455a3cfe37e327a4193e31d38dc1404bf70 |
|
MD5 | 846845be2603d3aedb01510bab9f68a3 |
|
BLAKE2b-256 | 35aa97f9b2cb93f1ff45b85451a0ff77f4e897eab289cfb3061dc0722271624c |
File details
Details for the file stencil_maker-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: stencil_maker-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b6c96415461c3feba44beee6fb798d56947fdfa6b2aa71340bb48202cb32d32 |
|
MD5 | 0897e881119024b65515f65a2fe7a25b |
|
BLAKE2b-256 | a74879b9b080c1bf6c7ec65848c6ad7e0a56c8ee0fcdf95eb06e0a6a6af7294a |