Skip to content

TextArtify is a simple yet powerful API that allows you to transform text into stunning images and add text overlays to existing images. Perfect for creating eye-catching graphics for social media, personalized greetings, and marketing materials, this API offers customizable options for fonts, colors, and layouts.

License

Notifications You must be signed in to change notification settings

DannyAkintunde/TextArtify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TextArtify: Text to Image API

Welcome to the Text to Image API, a simple Flask-based API that allows you to generate images from text, add text to existing images, and more. This API is designed to be easy to use and integrate into your applications.

Note

if you want to integrate this api into you personal or commercial projects I'll recommend you deploy the api rather than use e publicly available one.

Features

  • Convert text into images with customizable fonts, sizes, colors, and alignment.
  • Add text overlays to existing images.
  • Caching for improved performance.

Requirements

  • Python 3.x
  • Other depedencies in the requirements.txt

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/DannyAkintunde/TextArtify.git
    cd TextArtify
  2. Create a virtual environment and activate it:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install the required packages:

    pip install -r requirements.txt
  4. Run the application:

    flask run

The API will be available at http://127.0.0.1:5000.

Usage

You can interact with the API using tools like Postman or cURL. Below are the available endpoints.

API Endpoints

Text to Image

Endpoint: /api/v1/text-to-image
Method: GET or POST
Parameters:

  • text (required): The text to be converted into an image.
  • font: The font to use (optional).
  • font_size: The size of the font (default: 52).
  • color: The text color in hex format (default: #FFFFFFFF).
  • bg_color: The background color in hex format (default: #000000FF).
  • min_size: Minimum size of the image (optional).
  • max_size: Maximum size of the image (optional).
  • text_align: Alignment of the text (optional, can be center, left, or right).
  • padding_ratio: Padding ratio for the text (default: 0.1).

Example Request:

curl -X POST "http://127.0.0.1:5000/api/v1/text-to-image" -H "Content-Type: application/json" -d '{"text": "Hello World", "font": "arimo-bold-italic"}' -o out.png

Add Text to Image

Endpoint: /api/v1/add-text-to-img
Method: GET or POST
Parameters:

  • text (required): The text to overlay on the image.
  • bg (required): URL of the background image.
  • font: The font to use (optional).
  • font_size: The size of the font (default: 52).
  • color: The text color in hex format (default: #FFFFFFFF).
  • text_align: Alignment of the text (optional, can be center, left, or right).
  • padding_ratio: Padding ratio for the text (default: 0.1).

Example Request:

curl -X POST "http://127.0.0.1:5000/api/v1/add-text-to-img" -H "Content-Type: application/json" -d '{"text": "Sample Text", "bg": "https://example.com/image.jpg"}'

Fonts

These are the currently supported fonts

  • arimo
    • arimo-regular
    • arimo-italic
    • arimo-bold
    • arimo-bold-italic
    • arimo-medium
    • arimo-medium-italic
    • arimo-semibold
    • arimo-semibold-italic
  • arizonia
    • arizonia-regular

to use any of this fonts just add it to the font param in your request

Example Request:

curl -X POST "http://127.0.0.1:5000/api/v1/text-to-image" -H "Content-Type: application/json" -d '{"text": "Hello World", "font": "arizonia-regular"}' -o out.png

Logging

Logging is configured to log messages at the INFO level. Errors and warnings are logged appropriately to help with debugging.

Deploy

Deploy your personal TextArtify server for more control.

Deploy with Vercel

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.


About

TextArtify is a simple yet powerful API that allows you to transform text into stunning images and add text overlays to existing images. Perfect for creating eye-catching graphics for social media, personalized greetings, and marketing materials, this API offers customizable options for fonts, colors, and layouts.

Resources

License

Stars

Watchers

Forks

Languages