Nodes/ComfyUI-YCNodes_Toolkit/Load Image Crop Expand
ComfyUI Node

Load Image Crop Expand

Crop and outpaint by dragging a box — no external editor

By yichengup·Created 10 months ago·Updated 4 months ago· 59
Load Image Crop Expand
    • image
    • mask
    • width
    • height
    image_base64
    crop_x0
    crop_y0
    crop_width512
    crop_height512
    aspect_ratiofree
    fill_color#000000

    ComfyUI has a weird blind spot: for everything you can do to an image inside the graph, actually framing a crop is still mostly "type numbers into a box and hope." Load Image Crop Expand - the class is ycImageCrop - is one author's answer. It draws the image right on the node face, lets you drag a white crop rectangle around it, and here's the interesting part: you can drag that rectangle past the image edges to expand outward into blank canvas. Crop and outpaint in one gesture, no Photoshop, no separate editor.

    It's the flagship of ComfyUI-YCNodes_Toolkit, a small one-author pack of frontend/UI nodes by yichengup (亦诚 on Bilibili). It's the most-searched node in the pack for a reason: it's the one you actually feel in your hands.

    How it works

    The image you upload lives in a hidden image_base64 widget. The node's JavaScript renders it on the face and tracks your crop box in pixels; on run, the backend builds a fresh canvas of crop_width × crop_height, copies the source pixels where the box overlaps the image, and fills whatever hangs over the edge with fill_color. Negative crop_x/crop_y values are how you expand left or up.

    The mask is the clever part. It's 1.0 where the canvas is expansion space and 0.0 where real image pixels are - so the mask is your outpaint region. Wire image and mask into a fill/inpaint model (Flux Fill, any inpaint node) and you've got a "crop tighter, then let the model finish the frame" loop that takes about ten seconds to set up.

    The inputs that matter

    • crop_x / crop_y - top-left of the box. Negative = expand left/up.
    • crop_width / crop_height - canvas size, up to 8192.
    • aspect_ratio - lock to 1:1, 4:3, 16:9, or leave "free".
    • fill_color - hex color of the expansion area.

    Outputs: image, mask, width, height. That's all you need to drive an outpaint pass.

    Installing

    The README is dead simple:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yichengup/ComfyUI-YCNodes_Toolkit
    

    Then restart ComfyUI. Or just search "ComfyUI-YCNodes_Toolkit" in ComfyUI Manager. Dependencies are only numpy and Pillow - no models to download, nothing heavy.

    Troubleshooting

    The README is half in Chinese, and two operational tips matter more than anything else in it. First: double-click while dragging to stop the box from following your mouse - a genuine annoyance if you don't know it exists. Second, expanding downward: because the canvas is fixed, you can't always stretch the box's bottom edge. Move the whole box down first (that frees up space below), then drag the top edge back up. If you ever get a blank 512×512 output, that's the "no image decoded" fallback - re-upload rather than trusting a stale base64 string.

    CategoryYCNode/utils

    Inputs (7)

    NameTypeDefaultDescription
    image_base64STRING
    crop_xINT0-4096–4096
    crop_yINT0-4096–4096
    crop_widthINT5121–8192
    crop_heightINT5121–8192
    aspect_ratioSTRINGfree
    fill_colorSTRING#000000

    Outputs (4)

    NameTypeDescription
    imageIMAGE
    maskMASK
    widthINT
    heightINT