Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yoongkang/txtimg
https://github.com/yoongkang/txtimg
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yoongkang/txtimg
- Owner: yoongkang
- License: mit
- Created: 2019-09-17T09:56:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T15:28:05.000Z (10 months ago)
- Last Synced: 2024-11-11T14:34:50.154Z (2 months ago)
- Language: Python
- Size: 106 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TxtImg
A library to easily create text-based images (e.g. images that primarily contain text).
This is just a thin layer on top of Pillow.
## Installation
This is compatible with Python 3.6 and above.
Run the following command to install:
```
$ pip install txtimg
```## Example
```python
from txtimg import TxtImgtext = """
What did Sushi A say to Sushi B?What's up B? (WASABI)
"""t = TxtImg()
img = t.generate_from_text(text)
img.save("wasabi.png")
```## Configuration
You can specify parameters to the `TxtImg` constructor:
* font - Font used for your text. This is a PIL ImageFont object
* base_img - You can specify a base image to use, rather than the default white background. This is a PIL Image object.
* horizontal_margin - Horizontal margin in pixels
* vertical_margin - Vertical margin in pixels
* chars_per_row - Number of characters per row
* txt_color - A tuple representing the RGB values, e.g. (255, 0, 0) for red.