Imgix APIsRendering APITextText Fit Mode

Text Fit Mode

txt-fit

Enables a fit mode for the text.

ValueBehavior
(absent)Single line, clipped to fit the bounds (see txt-clip). The default.
maxSingle line, scaled down to fit within the bounds rather than clipping.
wrapWraps onto multiple lines: explicit newlines break lines, and lines wrap at the box width. A line that doesn’t fit the box height is dropped whole, never cut.
wrapmaxWraps the same way as wrap, then scales the whole block down uniformly to fit. No line is lost, and the block never scales up.

Any other value (including a combination like wrap,max) is unrecognized and falls back to single line.

The txt-pad and txt-width parameters are used to control the bounding region.

Multi-line text with wrap and wrapmax

Pass a newline as %0A within txt (or a literal line break within txt64) to start a new line; \r\n counts as a single break, and blank lines are kept.

https://assets.imgix.net/photo.jpg?w=800&txt=A%20long%20caption%20that%20runs%0Aover%20several%20lines&txt-fit=wrap&txt-width=400&txt-align=middle,center

The bounding box is the canvas minus txt-pad on each side, narrowed to txt-width if set (scaled by DPR, like txt-pad, the same as for single-line text). txt-x/txt-y place the block’s top-left corner, and the box extends through whatever room is left below and to the right of that point. The horizontal part of txt-align aligns each line and places the block; the vertical part places the block within the box. txt-lead controls the space between lines, in pixels (also scaled by DPR).

txt-clip is ignored by wrapped text. A single word wider than the box breaks inside the word rather than shrinking (the same rule the ~text endpoint uses); under wrapmax, a single glyph that still doesn’t fit shrinks to the box at any alignment. CJK text breaks between characters, and emoji keep their color glyphs.

wrap/wrapmax are a per-layer style like any other — one text layer can wrap while another stays single-line.

Default differs from video

On video, Iris wraps text by default. On still images, single-line stays the default so no existing image URL changes behavior — opt in with txt-fit=wrap or txt-fit=wrapmax.