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
From PyPI
$ pip install stencil_maker
To install with the server mode enabled, include the [server]
extra feature when installing:
$ pip install 'stencil_maker[server]'
From prebuilt packages
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
$ # Or with server mode
$ pip install 'stencil_maker-VERSION-py3-none-any.whl[server]'
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.1.tar.gz
.
File metadata
- Download URL: stencil_maker-0.1.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd8ce727318e688d103184cbdbfd2ee3ce491b3ebb23e864bdb9ba9efa3951ca |
|
MD5 | 82c097161c14dc7467e1703c9343599d |
|
BLAKE2b-256 | 6d8a55c2e9e36b9c992ddddb1b9bac0435c8902807d6bade9af87cf63b8fadda |
File details
Details for the file stencil_maker-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: stencil_maker-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.9 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 | be72dea435762a19d94ae2317cbd2c4ce56fcdabb7510bce5271dbc6eb5bca88 |
|
MD5 | b4425d5a9dc2e0a2bbc1947aba53f787 |
|
BLAKE2b-256 | a11c1c13cdf7508564fdab43103b9fed50d9e0af17bbbe60f14f693a552ba27a |