Nodes/VK Nodes/Tiled Crop Node
ComfyUI Node

Tiled Crop Node

It does the center-crop math so your grid cells actually line up

By VK·Created about a year ago·Updated about a year ago· 0
Tiled Crop Node
    • crop_width
    • crop_height
    • crop_x
    • crop_y
    • min_resolution
    • tile_string
    render_config{}
    start_time0.00

    Tiled Crop Node answers one deceptively simple question: "I'm putting a character into a grid cell with a given aspect ratio - what rectangle of their source image should I actually render?" When your source still is 1:1 and the target cell is 16:9 (or the reverse), something has to give. This node decides what and computes the numbers for you.

    How it works

    It takes a render_config JSON string - the one Tiled Setup Node emits - plus a start_time, and does aspect-ratio math on them. It reads the starting image dimensions and the computed tile dimensions out of the config, then compares their ratios:

    • If the source is wider than the tile, it crops the width down to match, centered.
    • If the source is taller, it crops the height instead.

    Either way the crop is centered horizontally (crop_x is computed, crop_y stays 0), which is the sane default for a character framing - you want them in the middle, not shoved left.

    The start_time input exists because this pack renders video in segments. Pass a nonzero start time and the node tags it onto the output tile_string (you get something like 2.5_8x8), which stops per-timestep outputs from overwriting each other downstream in Tiled Render. Zero keeps the plain string.

    Outputs

    Six of them, and they're mostly plumbing:

    • crop_width, crop_height, crop_x, crop_y - the rectangle, ready to feed into a Crop/ImageCrop-style node.
    • min_resolution - the smaller of the two tile dimensions, handy as a floor if you're sizing a sampler's latent around the tile.
    • tile_string - the tile identifier, with the start_time prefix added when applicable.

    If the config JSON is malformed, it doesn't crash - it logs an error and returns a zeroed crop plus an 8x8 tile string. Defensive, if not exactly helpful; worth knowing when you see zeroes coming out.

    When you'd actually reach for it

    You're inside the VK tiled-render workflow: Tiled Setup computes the render config, you generate each character's content, and Tiled Crop tells you what portion of the source to keep so every cell matches the layout's aspect ratio. That's its whole job, and it does it well because it's a pure function - same config, same numbers, every time. The center-crop logic is also exactly the kind of thing you can mentally reimplement, but why bother; this exists precisely so you don't have to remember whether to crop width or height.

    Install and gotchas

    Pack install is the usual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/VK/vk-nodes
    

    or ComfyUI Manager → search "VK Nodes" → Install, then restart. No per-node dependencies beyond what the pack needs as a whole (ffmpeg, for the audio/render side of things).

    Two practical notes. First, render_config is a plain JSON string - wire it from Tiled Setup Node's render_config output rather than retyping it, or the crop won't match what the render node thinks it's doing. Second, the start_time here needs to agree with the start_time you feed Tiled Render later; if they drift apart you get cells that crop one clip and render another, which is a fun 20 minutes to debug. Keep the same source for both and you're fine.

    Categoryvk-nodes

    Inputs (2)

    NameTypeDefaultDescription
    render_configSTRING{}
    start_timeFLOAT0.00

    Outputs (6)

    NameTypeDescription
    crop_widthINT
    crop_heightINT
    crop_xINT
    crop_yINT
    min_resolutionINT
    tile_stringSTRING