Skip to main content

A Python library to create images with customizable text overlays.

Project description

TxtToImg

TxtToImg is a Python library that allows you to add text to an image, either by providing a URL for the background image or by generating a gradient background.

Installation

To install TxtToImg, you can use pip:

pip install TxtToImg

Usage

Here's an example of how to use the TxtToImg class:

from TxtToImg import Txt2Img

# Create an instance of the Txt2Img class
img_generator = Txt2Img(
    text="Hello, World!",
    url="https://example.com/background.jpg",
    width=800,
    height=600,
    text_color=(255, 255, 255),  # White text
    text_background_color=(0, 0, 0),  # Black background
    font_scale=2,
    font_thickness=3,
    text_position="center"
)

# Create the image
img_generator.create()

# Show the image
img_generator.show()

# Save the image
img_generator.download()

API

The TxtToImg class has the following methods:

  • __init__(self, text, url=None, width=800, height=600, **kwargs): Initializes the TxtToImg class with the specified parameters.
  • open_image_from_url(self): Downloads the image from the provided URL and returns it as a NumPy array.
  • create_gradient(self): Creates a gradient background image.
  • add_text(self, img): Adds the specified text to the image.
  • create(self): Generates the final image by either opening the image from the URL or creating a gradient background, and then adding the text to the image.
  • show(self): Displays the generated image using OpenCV.
  • download(self): Saves the generated image to a file with the same name as the text.

License

This project is licensed under the MIT License.

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

txttoimg-0.1.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

txttoimg-0.1.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file txttoimg-0.1.2.tar.gz.

File metadata

  • Download URL: txttoimg-0.1.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for txttoimg-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e51d3f5f17508e6a0efeb8e4ab3afea2f90c11fd2f40b276b84708637487a868
MD5 6fd4884a98d869fd86a100e43a369fa9
BLAKE2b-256 559288252302ba829cfc594d196758653cb77d6fbc6551037b037fb151b85571

See more details on using hashes here.

File details

Details for the file txttoimg-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: txttoimg-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for txttoimg-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7317cba25e4ffe8edda69124b5623c4d5e0b8e7b7168b9555d92419b8c14bf1
MD5 a1f614e66da4bd796c1a7ea840827956
BLAKE2b-256 3cd243fa8e2dc1b3f5b57d94d500c2eff9c8925947e95a707f2d7d40571e70bf

See more details on using hashes here.

Supported by

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