Prompt & Dimensions from LLM
ComfyUI custom node that resolves a Qwen Image 2.1 Prompt Enhancer JSON hint (rewritten prompt + aspect ratio/size) into a ready-to-use prompt and exact width/height.
Prompt & Dimensions from LLM
A ComfyUI custom node created exclusively for the Qwen Image 2.1 Prompt Enhancer family. It consumes the JSON hint the model emits and turns it into a ready-to-use prompt plus an exact image resolution.
Description
Qwen Image 2.1 Prompt Enhancer is a prompt-rewriting model that converts a short image request (in any language) into a detailed English prompt and a target size. This node consumes that output and resolves the final width and height for the downstream image-generation node.
It is designed for both published variants:
- Text-to-Image —
Qwen-Image-2.1-PE-T2I: emits{"rewritten_prompt": "...", "wh_ratio": "16:9"}. - Image-to-Image —
Qwen-Image-2.1-PE-I2I: emits{"rewritten_prompt": "...", "wh_ratio": "", "ratio_follow": "<image1>"}.
In both cases wh_ratio and ratio_follow are mutually exclusive — exactly one
carries a value.
Installation
cd ComfyUI/custom_nodes
git clone https://github.com/BleynChannel/ComfyUI-QwenImage-PromptExtractor.git
How it works
- Parses the JSON hint and validates the
rewritten_prompt. - Resolves the size in one of two mutually exclusive ways:
wh_ratio+megapixels→ computes width/height from the aspect ratio and target megapixels. The math matches ComfyUI's built-in Resolution Selector (1 MP = 1024 × 1024, rounded to the nearest multiple ofmultiple, default 8), so e.g.1:1 @ 1 MP → 1024 × 1024.ratio_follow→ copies the exact pixel size of the referenced input image (ignoring megapixels).
- Emits the final
prompt,width, andheight.
If both wh_ratio and ratio_follow are present, ratio_follow wins.
Inputs
| Input | Type | Description |
| --- | --- | --- |
| llm_prompt | String (multiline) | The JSON hint from the Qwen Image 2.1 PE model, e.g. {"rewritten_prompt": "...", "wh_ratio": "16:9"}. |
| megapixels | Float | Target size in megapixels, 0.1–16.0. Used only with wh_ratio; ignored with ratio_follow. |
| multiple | Int | Grid size to round to, 8–128 (step 4, default 8). Used only with wh_ratio. |
| images | Autogrow (image) | Up to 10 reference images, keys image0…image9. ratio_follow may reference one of them. |
The node is not tied to a specific generation model: it works with any text-to-image model set by width/height (e.g. Empty Latent Image).
Outputs
| Output | Type | Description |
| --- | --- | --- |
| prompt | String | The rewritten prompt (rewritten_prompt). |
| width | Int | Image width, in pixels. |
| height | Int | Image height, in pixels. |
Resources
Author
BleynChannel — [email protected]