Skip to main content

A library to easily create text-based images (e.g. images that primarily contain text).

Project description

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

from txtimg import TxtImg

text = """
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.

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

txtimg-0.0.9.tar.gz (94.3 kB view hashes)

Uploaded Source

Built Distribution

txtimg-0.0.9-py3-none-any.whl (94.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page