Nodes/ComfyUI-ArchAi3d-Qwen/πŸ“ Qwen Image Scale V2
ComfyUI Node

πŸ“ Qwen Image Scale V2

The scaler that preps your image for Qwen-VL edits β€” now with region cropping

By amir84ferdosΒ·Created 11 months agoΒ·Updated 5 months agoΒ· 70
πŸ“ Qwen Image Scale V2
  • image
  • mask
  • image_vl
  • image_latent
  • mask
  • latent_width
  • latent_height
  • stitch_data
  • debug_text
β—„crop_modedisabledβ–Ί
β—„crop_padding64β–Ί
β—„context_factor1.0β–Ί
β—„blend_pixels16β–Ί
β—„aspect_ratio_modeautoβ–Ί
β—„preferred_aspect_ratio16:9 (Panorama)β–Ί
β—„vl_target_area147456β–Ί
β—„vl_divisible_by32β–Ί
β—„latent_target_area1763584β–Ί
β—„latent_divisible_by32β–Ί
β—„latent_area_tolerance0.30β–Ί
β—„vl_use_latent_sourcetrueβ–Ί
β—„vl_ignore_latent_letterboxtrueβ–Ί
β—„vl_ignore_latent_croptrueβ–Ί
β—„vl_upscale_methodareaβ–Ί
β—„vl_cropdisabledβ–Ί
β—„vl_letterboxfalseβ–Ί
β—„latent_upscale_methodlanczosβ–Ί
β—„latent_cropdisabledβ–Ί
β—„latent_letterboxfalseβ–Ί
β—„debugtrueβ–Ί

Qwen-VL image editors are picky eaters. The vision encoder wants images at a specific scale - the pack's sweet spot is ~147K pixels (about 384Γ—384) and dimensions divisible by 32 - while the latent side of the graph wants something closer to a megapixel. Feed the encoder a raw 3000px photo and you're wasting context tokens; feed the sampler a tiny latent and the edit comes back mushy. ArchAi3D_Qwen_Image_Scale_V2 solves both at once: it produces two separate outputs - image_vl for the encoder, image_latent for the sampler - and keeps their aspect ratios pixel-aligned so the model isn't confused about what it's looking at.

What V2 adds over V1

V1 is the simpler version covered in its own article. V2 layers on region editing. Set crop_mode to mask_crop and feed a mask (white = the region you care about) and the node crops to the mask's bounding box with crop_padding pixels around it, then expands by context_factor (1.0 = no expansion, 1.5 = 50% extra context) so the model can see what surrounds the thing it's editing. That's how you say "redesign only the kitchen island" without drawing a rectangle by hand.

The second headline feature is the stitch_data output. When you crop for a region edit, you'll eventually want to paste the result back over the original. stitch_data carries the crop box, the original dimensions, and the blend_pixels feather width, so a stitch node (the pack's tooling expects this) can reassemble seamlessly. blend_pixels defaults to 16 - the feather width for that reassembly.

Inputs that matter

  • crop_mode - disabled (full-image, V1 behavior) or mask_crop (region editing).
  • crop_padding (64), context_factor (1.0), blend_pixels (16) - the region-editing trio above.
  • aspect_ratio_mode / preferred_aspect_ratio - auto snaps to the closest of 24 Qwen-friendly ratios (1:1, 3:4, 16:9, 21:9, 9:21…); manual lets you force one.
  • vl_target_area (147456) and latent_target_area (1763584) - the pixel budgets for encoder and latent outputs. Leave them unless you know why you're changing them.
  • vl_use_latent_source - defaults True: the VL image is derived from the processed latent for pixel-perfect alignment. The vl_ignore_latent_letterbox / vl_ignore_latent_crop toggles stop it from double-padding or double-cropping as a result.
  • debug - prints the full decision trail to the console. Turn it off once things work; it's verbose.

Outputs

image_vl (β†’ the Qwen encoder), image_latent (β†’ the VAE/latent path), mask (resized to match), latent_width / latent_height (for an empty-latent or size node), stitch_data (region mode), and debug_text.

Install and notes

Standard for the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/amir84ferdos/ComfyUI-ArchAi3d-Qwen.git
cd ComfyUI-ArchAi3d-Qwen && pip install -r requirements.txt

Or ComfyUI Manager β†’ search "ArchAi3d Qwen". One gotcha: in mask_crop mode the node forces stretch scaling (crop disabled on the latent) specifically so nothing shifts when you stitch back - don't fight it by re-enabling latent crop, you'll get a misaligned paste. And remember the pack's license: free personal, paid commercial.

CategoryArchAi3d/Qwen/Image

Inputs (23)

NameTypeDefaultDescription
imageIMAGEβ€”
crop_modeoptCOMBOdisableddisabled: Use full image (V1 behavior). mask_crop: Crop to mask region with padding/context.
crop_paddingoptINT640–512Fixed pixel padding around mask bounding box.
context_factoroptFLOAT1.01–3Context expansion factor (1.0 = no expansion, 1.5 = 50% extra context). Applied after padding.
blend_pixelsoptINT160–128Feather width for seamless blending in stitch node.
aspect_ratio_modeoptCOMBOautoAuto: Find closest preferred aspect ratio. Manual: Use selected ratio.
preferred_aspect_ratiooptCOMBO16:9 (Panorama)Manually select preferred aspect ratio (only used in manual mode).
vl_target_areaoptINT1474563000–500000Target pixel area for QwenVL output (~147K optimal).
vl_divisible_byoptINT321–256VL dimensions divisible by this number.
latent_target_areaoptINT17635843000–4500000Target pixel area for latent output.
latent_divisible_byoptINT321–256Latent dimensions divisible by this number.
latent_area_toleranceoptFLOAT0.300.1–0.8Flexibility for latent pixel count (Β±%).
vl_use_latent_sourceoptBOOLEANtrueTrue: Use Latent as VL source (pixel-perfect). False: Use original input.
vl_ignore_latent_letterboxoptBOOLEANtrueWhen using Latent source, ignore vl_letterbox setting.
vl_ignore_latent_cropoptBOOLEANtrueWhen using Latent source, ignore vl_crop setting.
vl_upscale_methodoptCOMBOareaResampling algorithm for VL.
vl_cropoptCOMBOdisabledCrop mode for VL output.
vl_letterboxoptBOOLEANfalseAdd black bars to preserve aspect ratio.
latent_upscale_methodoptCOMBOlanczosResampling algorithm for latent.
latent_cropoptCOMBOdisabledCrop mode for latent output. disabled: stretch to fit (no content lost). center: crop to fill frame.
latent_letterboxoptBOOLEANfalseAdd black bars to latent.
maskoptMASKMask for crop mode (white = region to crop) and output scaling.
debugoptBOOLEANtrueShow detailed debug info.

Outputs (7)

NameTypeDescription
image_vlIMAGEβ€”
image_latentIMAGEβ€”
maskMASKβ€”
latent_widthINTβ€”
latent_heightINTβ€”
stitch_dataSTITCH_DATAβ€”
debug_textSTRINGβ€”