Prompt & Dimensions from LLM
The Parser That Makes Enhancer Output Usable
- images
- prompt
- width
- height
The name promises more than it delivers, in a good way. Prompt & Dimensions from LLM does not call an LLM, needs no API key, and loads no model. It's a text parser with a bit of arithmetic attached, and that's exactly why it earns a slot in your graph.
Here's the situation it exists for. LLM-assisted prompting isn't a novelty any more - corpus mentions of "prompt enhancer" went from 12 in 2023 to 253 in the first half of 2026 - and the trouble is what those enhancers hand back. Not a nicer prompt, but chat: preamble, markdown, a size suggestion buried in prose. This node takes the structured version of that output - a small JSON hint - and turns it into two things the graph can consume: a clean string and a real pixel size.
What the hint looks like
The pack ships exactly one node, and it expects a JSON object like this:
{"rewritten_prompt": "a wide cinematic shot of ...", "wh_ratio": "16:9"}
or, for an edit-style enhancer that copies a reference image's framing:
{"rewritten_prompt": "restyle this ...", "wh_ratio": "", "ratio_follow": "<image1>"}
That goes in the llm_prompt box, and wh_ratio and ratio_follow are meant to be mutually exclusive - exactly one carries a value. You usually paste it in from whatever Qwen-Image-2.1 prompt-enhancer variant you're running, or from any LLM you've told to emit those keys. The node doesn't care where the JSON comes from, and it isn't tied to a specific generator: key lookup is case-insensitive, so Rewritten_Prompt still works, and extra keys are ignored. What it won't tolerate is an empty string, a non-object JSON root, or a missing rewritten_prompt - each gets its own explicit error instead of a silent empty prompt.
How the size gets resolved
Two paths, and the tie-breaker matters: if both fields are present, ratio_follow wins. Your megapixels widget does nothing in that case.
With wh_ratio present, the node does the same math as ComfyUI's built-in Resolution Selector. Pixel budget is megapixels × 1024 × 1024, so 1 MP really is 1024×1024 at 1:1. Each dimension then snaps to a multiple of multiple: 16:9 at 1 MP lands on 1368×768 - a hair off an exact 16:9, same as every other sizing node in the ecosystem. The multiple tooltip says dimensions are "rounded up", but the code rounds to the nearest multiple, floored at 8. Trust the code.
With ratio_follow, the node reads the actual tensor dimensions of whichever reference image you wired into the images input (up to 10 slots) and copies them verbatim, ignoring megapixels entirely. The reference must be spelled <imageN>, angle brackets included - <image1> works, image1, <1> and <image 1> don't. The index is 1-based over the images you actually provided, so <image1> means the first one you plugged in (internally image0, the socket labelled image0). Ask for a slot you left empty and you get an error listing what was provided.
Wiring it up
Three outputs: prompt (STRING), width and height (both INT). Send prompt to a CLIP text encode, and width/height into Empty Latent Image or any node that takes a canvas size.
Two settings matter. megapixels (default 1.0) is the pixel budget on the wh_ratio path; the 16 MP ceiling is generous, and since most current models degrade softly above their 1–2 MP native band, having the option isn't a reason to use it. multiple snaps the result to a grid - bump it to 64 for Flux, which wants dimensions divisible by 64.
Install
ComfyUI Manager, search the pack title, or:
cd ComfyUI/custom_nodes
git clone https://github.com/BleynChannel/ComfyUI-QwenImage-PromptExtractor.git
Restart ComfyUI. There is no requirements.txt and no install.py - the logic is stdlib json, math and re in resolver.py, which is unusual for a plumbing pack and pleasant if you'd rather read what you're installing. The pyproject.toml declares requires-comfyui = ">=0.3.40" and the pack is authored against the V3 schema (comfy_api.latest, io.ComfyNode, comfy_entrypoint) - hence no NODE_CLASS_MAPPINGS, and no import on an older ComfyUI.
Where people get burned
- Fenced JSON. The single most common failure: your LLM wraps the object in
```json ... ```and the node throwsLLM prompt is not valid JSON. That's the enhancer's fault, not the node's. Strip the fences, or tell your model to emit raw JSON only. - Old ComfyUI. Missing
comfy_apion import, or animagesautogrow input that won't render. Update ComfyUI before filing anything. 16/9instead of16:9. Only the colon form parses; the slash form errors out.- Following a big reference image.
ratio_followcopies the size exactly, so a 4K reference hands a 3840×2160 canvas to a model that wants 1.5 MP - and it does that with yourmegapixelssetting silently ignored.
Zero community footprint for this pack as of writing, so all of the above comes from the shipped source rather than field reports. If you're already piping an enhancer into your graph, it's a small, honest adapter worth the slot.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| llm_prompt | STRING | JSON hint generated by the LLM. | |
| megapixels | FLOAT | 1.00.1–16 | Target size in megapixels (0.1-16.0). Only used when wh_ratio is provided; ignored when ratio_follow is used. |
| multiple | INT | 88–128 | Pixel grid that resolved width/height are rounded up to (default 8). Only used when wh_ratio is provided. |
| images | COMFY_AUTOGROW_V3 | Up to 10 reference images. ratio_follow can name one of them (e.g. '<image1>') to reuse its exact size. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |
| width | INT | — |
| height | INT | — |