POST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 import requests import base64 # Use this function to convert an image file from the filesystem to base64 def image_file_to_base64(image_path): with open(image_path, 'rb') as f: image_data = f.read() return base64.b64encode(image_data).decode('utf-8') # Use this function to fetch an image from a URL and convert it to base64 def image_url_to_base64(image_url): response = requests.get(image_url) image_data = response.content return base64.b64encode(image_data).decode('utf-8') api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/text-overlay" # Request payload data = { "align": "right", "base64": False, "blend_mode": "normal", "color": "#FFF", "font": "JosefinSans-Bold", "font_size": 150, "graphspace": 0, "image": "https://segmind-sd-models.s3.amazonaws.com/display_images/txt_overlay_in.png.jpeg", "image_format": "jpeg", "image_quality": 90, "linespace": 10, "margin_x": 97, "margin_y": 300, "outline_color": "#11ff00", "outline_size": 0, "text": "TRAVEL\n TODAY", "text_underlay": True, "wrap": 50 } headers = {'x-api-key': api_key} response = requests.post(url, json=data, headers=headers) print(response.content) # The response is the generated image
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


alignenum:str ( default: right )

Text alignment

Allowed values:


base64bool ( default: 1 )

Output image as base64 format


blend_modeenum:str *

Blend mode for text overlay

Allowed values:


colorstr ( default: #FFF )

Text color


fontenum:str ( default: JosefinSans-Bold )

Font style for the text

Allowed values:


font_sizeint ( default: 150 )

Font size for the text

min : 1,

max : 2500


graphspaceint ( default: 1 )

Controls spacing between text and surrounding elements.

min : 0,

max : 2048


imagestr *

URL of the image


image_formatenum:str ( default: webp )

Output image format.

Allowed values:


image_qualityint ( default: 90 )

Quality when saving the output images, from 0 to 100. 100 is best quality, 0 is lowest quality

min : 0,

max : 100


linespaceint ( default: 10 )

Space between lines

min : 0,

max : 2048


margin_xint ( default: 97 )

Margin X for positioning text

min : 0,

max : 2048


margin_yint ( default: 300 )

Margin Y for positioning text

min : 0,

max : 2048


outline_colorstr ( default: #11ff00 )

Outline color for text


outline_sizeint ( default: 1 )

Outline size for text

min : 0,

max : 2048


textstr *

Text to be displayed on the image


text_underlaybool ( default: true )

Specifies whether the text should be rendered behind an object or remain in front of it


wrapint ( default: 50 )

Wrap width for text

min : 0,

max : 2048

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Text Overlay Model - Enhance Your Images with Custom Text

Enhance the visual appeal of your images effortlessly with our Text Overlay Model. With this tool, you can seamlessly add customized text to any image, making it ideal for social media posts, marketing materials, blog images, and more. Our model provides a user-friendly interface and powerful customization options to suit your creative needs.

Key Features:

Easy Text Customization

  • Text Input: Simply type the text you want to overlay on your image.

  • Font Options: Choose from a vast array of fonts to match your style. The Altura-Regular font is one of many available for your convenience.

  • Alignment: Adjust text alignment to leftcenter, or right to suit your image layout.

Advanced Styling Options

  • Text Color: Select any hex color code to perfectly match your text with the image. For example, use #0000FF for blue text.

  • Outline Color: Add an outline to your text with customizable colors. For example, use hex code #11FF00 for a green outline.

  • Blend Mode: Choose from several blend modes such as normalmultiply, and more to achieve the desired text and image integration.

  • Text Underlay: Enable or disable underlay to make sure your text stands out.

Precise Positioning

  • Marginal Adjustments: Fine-tune the position of your text with Margin X and Margin Y settings. For example, use 150 for Margin X and 350 for Margin Y.

  • Wrap and Graphspace: Control text wrapping and spacing with settings like Wrap (set to 50) and Graphspace.

Flexible Layout

  • Line Spacing: Customize the spacing between lines of text, set to 10 for optimal readability.

  • Font Size: Adjust the size of the text to match your design requirements, with a flexible range (Example: 170 for a bold statement).

  • Outline Size: Define the thickness of your text outline to create a standout effect.

How to Use:

  1. Upload Your Image: Provide the image URL or upload directly from your device.

  2. Customize Your Text: Input your desired text and tweak the style options to match your vision.

  3. Adjust Position and Size: Use margin, wrap, and size settings to place the text perfectly.

  4. Generate: Click the generate button to see your customized text overlay seamlessly integrated onto your image.

Get creative and elevate your visuals with our intuitive Text Overlay Model. Perfect for digital marketers, graphic designers, and social media enthusiasts looking to add a personal touch to their images.