π Qwen Image Scale V2
The scaler that preps your image for Qwen-VL edits β now with region cropping
- image
- mask
- image_vl
- image_latent
- mask
- latent_width
- latent_height
- stitch_data
- debug_text
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) ormask_crop(region editing).crop_padding(64),context_factor(1.0),blend_pixels(16) - the region-editing trio above.aspect_ratio_mode/preferred_aspect_ratio-autosnaps to the closest of 24 Qwen-friendly ratios (1:1, 3:4, 16:9, 21:9, 9:21β¦);manuallets you force one.vl_target_area(147456) andlatent_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. Thevl_ignore_latent_letterbox/vl_ignore_latent_croptoggles 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.
Inputs (23)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| crop_modeopt | COMBO | disabled | disabled: Use full image (V1 behavior). mask_crop: Crop to mask region with padding/context. |
| crop_paddingopt | INT | 640β512 | Fixed pixel padding around mask bounding box. |
| context_factoropt | FLOAT | 1.01β3 | Context expansion factor (1.0 = no expansion, 1.5 = 50% extra context). Applied after padding. |
| blend_pixelsopt | INT | 160β128 | Feather width for seamless blending in stitch node. |
| aspect_ratio_modeopt | COMBO | auto | Auto: Find closest preferred aspect ratio. Manual: Use selected ratio. |
| preferred_aspect_ratioopt | COMBO | 16:9 (Panorama) | Manually select preferred aspect ratio (only used in manual mode). |
| vl_target_areaopt | INT | 1474563000β500000 | Target pixel area for QwenVL output (~147K optimal). |
| vl_divisible_byopt | INT | 321β256 | VL dimensions divisible by this number. |
| latent_target_areaopt | INT | 17635843000β4500000 | Target pixel area for latent output. |
| latent_divisible_byopt | INT | 321β256 | Latent dimensions divisible by this number. |
| latent_area_toleranceopt | FLOAT | 0.300.1β0.8 | Flexibility for latent pixel count (Β±%). |
| vl_use_latent_sourceopt | BOOLEAN | true | True: Use Latent as VL source (pixel-perfect). False: Use original input. |
| vl_ignore_latent_letterboxopt | BOOLEAN | true | When using Latent source, ignore vl_letterbox setting. |
| vl_ignore_latent_cropopt | BOOLEAN | true | When using Latent source, ignore vl_crop setting. |
| vl_upscale_methodopt | COMBO | area | Resampling algorithm for VL. |
| vl_cropopt | COMBO | disabled | Crop mode for VL output. |
| vl_letterboxopt | BOOLEAN | false | Add black bars to preserve aspect ratio. |
| latent_upscale_methodopt | COMBO | lanczos | Resampling algorithm for latent. |
| latent_cropopt | COMBO | disabled | Crop mode for latent output. disabled: stretch to fit (no content lost). center: crop to fill frame. |
| latent_letterboxopt | BOOLEAN | false | Add black bars to latent. |
| maskopt | MASK | Mask for crop mode (white = region to crop) and output scaling. | |
| debugopt | BOOLEAN | true | Show detailed debug info. |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| image_vl | IMAGE | β |
| image_latent | IMAGE | β |
| mask | MASK | β |
| latent_width | INT | β |
| latent_height | INT | β |
| stitch_data | STITCH_DATA | β |
| debug_text | STRING | β |