| x | No | create only: the layer's left edge in document pixels. | |
| y | No | create only: the layer's top edge in document pixels. | |
| op | Yes | create: a new text layer at the top of the stack with `text` at `x`/`y` (default 100,100) and `font_size` (default 24), optionally with font_name, red/green/blue and alignment. set_content: replace the text with `text`. set_font: set `font_name`, `font_size`, or both (omit font_name to resize in the current font). set_color: set red/green/blue. set_alignment: set `alignment`. set_box: put the layer in a fixed `box` (re-wrapping its text). The set_* ops act on the text layer named by `layer_id` or `layer`. | |
| box | No | create, set_box: a fixed text box {width, height?} in image pixels (each side 1 to 30000, area within the text-box cap: 64 MP at 8-bit, 32 MP at 16-bit, 16 MP at 32-bit). The text wraps at `width` (newlines in the text are kept) and is placed at the top of the box; there is no vertical alignment, so a taller box leaves the space below. Omit `height` and the layer grows to the wrapped text's height. The box survives later set_content / set_font / set_alignment edits. Emoji and some scripts depend on installed fonts and may render as empty boxes. | |
| fit | No | create, set_box: with a `box` that has both width and height (at most 16 MP), shrink the text to approximately the largest size (at most font_size, or the current size for set_box) at which the wrapped text fits inside the box, searched in at most 12 trial renders. A word wider than the box counts as not fitting. The result reports `fitted`: false when even min_size overflows (the text is left at min_size). | |
| red | No | Text colour red, 0-255. red, green and blue go together. | |
| blue | No | Text colour blue, 0-255. | |
| text | No | create: initial text. set_content: the new text, replacing the existing text. At most 2000 characters. For a line break, put a newline character in the string (not a backslash followed by n). | |
| green | No | Text colour green, 0-255. | |
| image | Yes | Image id, as returned by open_photo. | |
| layer | No | set_*: name of the text layer to change. Ignored when layer_id is given. Not used by create. | |
| layer_id | No | set_*: id of the text layer to change (create reports it; inspect flags text layers with is_text_layer). Takes priority over `layer`. Not used by create. | |
| min_size | No | fit only: the smallest font size to try, in pixels (default 8). | |
| alignment | No | Text alignment: LEFT, CENTER, RIGHT or FULLYJUSTIFIED (the justified-with-last-line variants are refused). In a box, alignment applies within the box width. | |
| font_name | No | Font family ("Inter", "Open Sans") or full name ("Inter Bold"), case-insensitive. create: omit for a default sans. A name that matches nothing is refused with the closest installed names; inspect what=fonts lists them all. | |
| font_size | No | Font size in points, 1 to 1296, converted to pixels with the image resolution. create: initial size (default 24). set_font: new size (omit to keep the current size). | |