JLC Load, Resize & Encode Image
The image loader that ends 'latent size mismatch' errors
- vae
- image
- mask
- width
- height
- latent
Load a reference image, drag an inpaint mask onto the canvas, and the moment you hit "Queue" the run dies because your image is 833×611 and the model wants dimensions divisible by 8. JLC Load & Resize Image exists so that stop being a problem. It's a drop-in image loader that resizes the image and its mask together, preserves aspect ratio, and rounds the final dimensions down to whatever multiple you need - 16 by default - so the output actually fits the latent space. It's from jlc-comfyui-nodes (J. L. Córdova / Damkohler), and it's modeled on the KJNodes "Load & Resize Image" idea without requiring KJNodes itself.
How it works
Under the hood it subclasses ComfyUI's own LoadImage, so you get the exact upload / drag-and-drop contract you already know - the image widget is a dropdown plus upload button, drag a file onto the node and it lands in your input folder. Then the resize logic kicks in. Unlike a freeform width/height resize node, every mode here preserves aspect ratio; the divisible_by rounding happens after, and it rounds down (never silently upscaling your image) and clamps a tiny edge to one divisor so output stays valid.
The part beginners miss until they hit it: the mask output is resized to exactly the same dimensions as the image, and images with no alpha still get a correctly sized all-zero mask. That lockstep behavior is why you don't get the classic mismatch where your mask is a different size than your image and the inpaint node refuses to cooperate.
The inputs that matter
Pick your resize mode with resize_by, and the frontend shows only the numeric widget that mode uses:
scale by multiplier→multiplier(2.0 doubles both dimensions)scale longer dimension→longer_size(default 1024)scale shorter dimension→shorter_sizescale width→width, orscale height→height(the other edge is derived from aspect ratio)scale total pixels→megapixels(1024×1024 per megapixel)
Then two settings apply everywhere: scale_method (area for downscaling, lanczos for upscaling - the tooltips' own advice) and divisible_by (default 16; use 1 to disable). For Flux workflows people often want 16 or 32; for most SDXL-era models 8 is enough. If you've ever fought a "latent size mismatch," this is the widget that does the fighting for you.
Outputs are image (BHWC), mask (BHW), and two INTs - width and height. Those INTs are the quiet MVP here: wire them into an Empty Latent's width/height and your sampling resolution is guaranteed to match what the node produced.
Install
ComfyUI Manager (search JLC ComfyUI Nodes, it's on the registry), or:
cd ComfyUI/custom_nodes
git clone https://github.com/Damkohler/jlc-comfyui-nodes.git
Restart after installing or git pull-ing. No model downloads and no extra Python dependencies for this node.
Honest positioning
If you already run KJNodes, its Load & Resize Image does the same job and you don't need this one. But within a JLC pack, this node pairs naturally with the Padded Image / Padded Latent utilities for inpainting and outpainting workflows - load a source at the right aspect ratio, pad it onto a canvas, and the dimensions all stay consistent. The one thing it deliberately does not do is let you set width and height independently and squish the aspect ratio - that's a feature, not a bug, and if that's what you actually need, a plain Resize node is the tool. For everything else, this loader quietly removes a whole class of "why won't my workflow run" errors.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMBO | 1 options: example.png | |
| resize_by | COMBO | scale longer dimension | Aspect-ratio-preserving resize policy. The frontend shows only the numeric control used by this mode. |
| multiplier | FLOAT | 1.000.01–8 | Scale factor; 2.0 doubles both dimensions. |
| longer_size | INT | 10241–16384 | Target size of the source image's longer edge. |
| shorter_size | INT | 10241–16384 | Target size of the source image's shorter edge. |
| width | INT | 10241–16384 | Target width; height is calculated from aspect ratio. |
| height | INT | 10241–16384 | Target height; width is calculated from aspect ratio. |
| megapixels | FLOAT | 1.000.01–64 | Target total megapixels using 1024×1024 per megapixel. |
| scale_method | COMBO | area | Interpolation method. Area is generally strong for downscaling; Lanczos is often useful for upscaling. |
| divisible_by | INT | 161–512 | After aspect-ratio calculation, round width and height down to this multiple. Use 1 to disable. |
| vaeopt | VAE | Optional. When connected, encodes the final resized IMAGE and returns it through the LATENT output. Without a VAE, LATENT returns None. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| width | INT | — |
| height | INT | — |
| latent | LATENT | — |