ForHosting KIT · Images

Meme text layout generator

The meme text layout generator turns an image width, image height, and two captions into practical drawing instructions.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

It selects one readable font size for both captions, wraps each caption, and returns pixel bounding boxes anchored near the top and bottom edges. The calculation is deterministic, so identical input always produces identical coordinates. Use the result with Canvas, SVG, an image library, or a rendering service when you need consistent meme typography without trial-and-error resizing.

Supply the canvas and both captions

Enter the image width and height in pixels, followed by the text that belongs at the top and bottom. Both captions are required because the purpose of this layout is to balance a complete two-caption meme. Whitespace at the beginning and end is removed, and repeated whitespace inside a caption is normalized before measurement. An empty caption therefore produces an input error instead of a misleading zero-sized box. Dimensions must be whole numbers from 64 through 10,000 pixels, while each caption may contain up to 500 characters. Those bounds keep the calculation predictable in both an interactive page and an automated workflow. The returned margin is based on the shorter image dimension, which produces visually similar edge spacing for portrait, landscape, and square images. If your source image is resized before rendering, run the calculation with the final dimensions rather than scaling old coordinates; this preserves wrapping decisions, line spacing, and alignment at the size that viewers will actually see.

Understand how fitting and wrapping work

The calculator chooses a single integer font size shared by both captions. It starts from a size derived from the image dimensions and tests progressively smaller sizes until the top and bottom blocks both fit. Each caption can use up to forty-two percent of the usable image height, leaving separation between the two regions even when both texts wrap across several lines. Words are kept intact whenever possible. A word that is wider than the usable area is split into smaller pieces so that its box never extends beyond the image. Width estimates use a stable built-in profile for bold, condensed meme lettering: narrow characters consume less space, while wide capitals consume more. This is an analytic layout estimate rather than a browser font measurement, so the rendering font can affect the final visual edge by a few pixels. For the closest match, use a bold condensed face with metrics similar to Impact, apply the returned line height, center every returned line, and treat the boxes as the reserved drawing regions.

Render the returned pixel geometry

The result includes the selected font size, line height, outer margin, and separate top and bottom objects. Each caption object contains its wrapped lines plus an x coordinate, y coordinate, width, and height in pixels. The top box begins at the calculated margin. The bottom box ends at the same margin above the lower edge, which keeps its placement stable no matter how many lines it contains. Draw lines from the box’s y coordinate in line-height increments and center them horizontally within the full image. If your graphics API positions text by baseline rather than by the top of its line box, add the font ascent appropriate to your chosen typeface before drawing. Stroke width, shadow, capitalization, and color are intentionally outside this capability: they change appearance but not the reserved caption geometry. For automated generation, store these layout values beside the source captions so the same approved composition can be reproduced across renderers, queues, and later image revisions without repeating manual font-size experiments.

Build a meme generator

Calculate consistent caption geometry before drawing text onto user-selected image templates.

Prepare Canvas or SVG commands

Convert two captions into wrapped lines and pixel boxes that a frontend renderer can consume directly.

Automate social image production

Create repeatable layouts for batches of captioned images without manually testing a series of font sizes.

What does the calculation cost?

Each API request costs $0.002. The same deterministic calculation can also run in the browser.

Why must both captions contain text?

This capability calculates a balanced two-caption meme layout. An empty or whitespace-only top or bottom caption is rejected as invalid input.

Does the result modify my image?

No. It returns font and geometry data only. Use those values with your preferred image, Canvas, or SVG renderer.

Which font should I use when rendering?

A bold condensed font with metrics similar to Impact will most closely match the built-in width estimates.

Can a long word extend outside the image?

No. A word wider than the usable area is divided into pieces during wrapping so every returned box stays within the horizontal margins.

Why do the top and bottom captions share a font size?

A shared size gives the finished meme consistent visual weight. The smaller size required by either caption becomes the size for both.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/image/meme-text-layout

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/image/meme-text-layout \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"width":1200,"height":800,"top_caption":"WHEN THE TESTS PASS","bottom_caption":"ON THE FIRST TRY"}'
{
  "width": 1200,
  "height": 800,
  "top_caption": "WHEN THE TESTS PASS",
  "bottom_caption": "ON THE FIRST TRY"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "image.meme_text_layout",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_width10000
max_height10000
max_chars500
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →