Skip to content
Browse all functions

Convert Texts to an Image

images/text2image

text2image (Convert Texts to an Image) is a 1001fx API function in the group Images: POST https://api.1001fx.com/images/text2image, 3 credits per item. It works as a ready-made module in Make and n8n or as a plain HTTP call.

3 credits per itemHTTP APIn8nMake

Converts multiple texts on a colored background and creates an image. Transparent backgrounds allow overlay on another image.

Try it in the 1001fx app

Run text2image in your browser with your API key – fill the form, click Run and get the answer or the file.

text2image in the 1001fx app: the form with example values
Convert Texts to an Image in the 1001fx app

Endpoint

POSThttps://api.1001fx.com/images/text2image
Header
X-API-KEY: YOURSECRETAPIKEY How to
Content type
application/json

Parameters

  • backgroundColorstring (HEX Color)optional

    The image background color. Transparent if empty.

    Example:
    #2563EB
  • widthnumberrequired

    The image width.

    Min:
    1
    Max:
    10000
    Example:
    500
  • heightnumberrequired

    The image height.

    Min:
    1
    Max:
    10000
    Example:
    500
  • dataarray<object>required

    Data to be displayed

    • textstringrequired

      The text to print.

      Example:
      Hello from 1001fx!
    • xnumberrequired

      The x position from the top left corner.

      Example:
      0
    • ynumberrequired

      The y position from the top left corner.

      Example:
      0
    • maxWidthnumberrequired

      The maximum width of your textarea.

      Min:
      1
      Example:
      500
    • maxHeightnumberrequired

      The maximum height of your textarea.

      Min:
      1
      Example:
      500
    • alignmentXenumoptional

      Horizontal text alignment. Defaults to 'left'.

      Values:
      left
      center
      right
      Default:
      left
      Example:
      center
    • alignmentYenumoptional

      Vertical text alignment. Defaults to 'top'.

      Values:
      top
      middle
      bottom
      Default:
      top
      Example:
      middle
    • fontSizeenumoptional

      Fontsize of your text. Default to 'auto'.

      Values:
      8
      16
      32
      64
      128
      auto
      Default:
      auto
      Example:
      64
    • textColorstring (HEX Color)required

      The text color. Defaults to '#000000'.

      Default:
      #000000
      Example:
      #EC4899a0

Examples

Print text on custom background

Returns a new image (custom background)

Input

Expects a background and texts as data array to display
{
  "height": 1000,
  "width": 1000,
  "backgroundColor": "#000000",
  "data": [
    {
      "text": "Alice",
      "x": 0,
      "y": 0,
      "maxWidth": 500,
      "maxHeight": 400,
      "textColor": "#fff123"
    },
    {
      "text": "Bob",
      "x": 0,
      "y": 200,
      "maxWidth": 500,
      "maxHeight": 400,
      "textColor": "#fff123"
    }
  ]
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "image/png"
  }
}
Show curl command
curl -X POST 'https://api.1001fx.com/images/text2image' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"height":1000,"width":1000,"backgroundColor":"#000000","data":[{"text":"Alice","x":0,"y":0,"maxWidth":500,"maxHeight":400,"textColor":"#fff123"},{"text":"Bob","x":0,"y":200,"maxWidth":500,"maxHeight":400,"textColor":"#fff123"}]}'

Print text on transparent

Returns a new image on a transparent background

Input

Expects an height and weight texts as data array to display
{
  "height": 1000,
  "width": 1000,
  "data": [
    {
      "text": "Alice",
      "x": 0,
      "y": 0,
      "maxWidth": 500,
      "maxHeight": 400,
      "textColor": "#fff123"
    },
    {
      "text": "Bob",
      "x": 0,
      "y": 200,
      "maxWidth": 500,
      "maxHeight": 400,
      "textColor": "#fff123"
    }
  ]
}

Output · HTTP 200

Result is a single file.
{
  "statusCode": 200,
  "headers": {
    "content-type": "image/png"
  }
}
Show curl command
curl -X POST 'https://api.1001fx.com/images/text2image' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"height":1000,"width":1000,"data":[{"text":"Alice","x":0,"y":0,"maxWidth":500,"maxHeight":400,"textColor":"#fff123"},{"text":"Bob","x":0,"y":200,"maxWidth":500,"maxHeight":400,"textColor":"#fff123"}]}'

Try text2image now

Run it in your browser or create a free account and get 100 credits every month.

Changelog

  • 1.0.016.02.2023created
Ask 1001fx