ComfyUI Node

Qwen Image Prep

Fix 'Qwen Vision Encoder Shape Error' Before It Happens

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Qwen Image Prep
  • image
  • image
  • width
  • height
  • info
resolution448x448
resize_modecrop
interpolationbicubic
custom_width448
custom_height448

Qwen's vision encoders are picky eaters. They don't accept arbitrary image dimensions - they want resolutions that are multiples of 14, and if you hand them a 1031×783 PNG, you get a shape mismatch error that kills the whole graph. Qwen Image Prep exists to make that failure impossible: it resizes your image to a Qwen-compatible resolution before the encoder ever sees it, and reports exactly what it did.

This is one of those small nodes you only appreciate after the first time a Qwen-based captioner or VLM workflow dies on you mid-batch. It's not magic, it's a preflight check with knobs.

How it works

It parses your target resolution, forces the dimensions to be multiples of 14 (for custom, it snaps your inputs down to the nearest multiple of 14 automatically and tells you if it had to), then resizes according to resize_mode:

  • crop (default) - scale to fit and center-crop. Maintains aspect ratio, loses edges.
  • pad - scale to fit and pad the rest. Maintains aspect ratio, keeps everything, adds borders.
  • stretch - plain resize. No loss, but distorts the aspect ratio.

It also normalizes channels: grayscale gets repeated to RGB, RGBA drops its alpha, anything with more than 3 channels gets truncated. Output is clamped to 0-1 and always exactly 3 channels, which is what the encoders expect.

Inputs that matter

  • resolution - presets from 224×224 up to 672×672, or custom. 448×448 is the default and a solid starting point.
  • resize_mode - crop is usually right; pick pad if you can't afford to lose content (and don't mind border artifacts).
  • interpolation - bilinear/bicubic/lanczos/nearest. Bicubic is the default for a reason; the "lanczos" option quietly maps to bicubic because PyTorch has no native lanczos - a small honest quirk.
  • custom_width / custom_height - used when resolution is custom, snapped to multiples of 14.

Four outputs: image (the prepared image), width and height (actual output dims, useful for feeding size-aware nodes), and info - a human-readable summary of input/output and mode, handy for a text display or just console logging.

Installing it

Part of TextureAlchemy:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

or via ComfyUI Manager (search "TextureAlchemy"), then restart. Under Texture Alchemist → Texture. No models, no dependencies - pure resize math on the image you feed it.

When you'd use it

Anywhere a Qwen-family encoder (Qwen2-VL, Qwen-Image captioners, VLM nodes) demands specific dimensions and you don't want to think about multiples of 14. The pack's naming leans toward texture work, but the node itself is general-purpose image prep - if a Qwen-based node downstream is rejecting your images, stick this in front of it and the shape error goes away.

CategoryTexture Alchemist/Texture

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
resolutionCOMBO448x448Target resolution (must be multiple of 14 for Qwen)
resize_modeCOMBOcropHow to fit image: stretch (distort), crop (maintain aspect), pad (add borders)
interpolationCOMBObicubicResampling method
custom_widthoptINT44814–4096Custom width (must be multiple of 14)
custom_heightoptINT44814–4096Custom height (must be multiple of 14)

Outputs (4)

NameTypeDescription
imageIMAGE
widthINT
heightINT
infoSTRING