Nodes/ComfyUI_UnfakePy_Warpper/Pixel IMG Upscale To Target
ComfyUI Node

Pixel IMG Upscale To Target

Nearest-neighbor upscale to ~1024, and square it up if you ask

By AhBumm·Created 11 months ago·Updated 9 months ago· 2
Pixel IMG Upscale To Target
  • image
  • upscaled_img
  • cropped_origin_img
target_resolution1024
crop_and_padfalse

This is the node for "I want my pixel art bigger, roughly this big, and possibly squared up." It upscales to approximately a target resolution - default 1024 on the longest side - using nearest-neighbor so the blocks stay crisp, and it has a separate mode that crops or pads the frames into a clean square first. It's batch-aware (the internal function is literally named process_gif, a tell that it's built for sprite sheets and frame sequences), which makes it handy when you're prepping a set of frames for a canvas or a training run.

How it works

The clever bit is in how it picks the scale. Rather than a naive resize to exactly the target, it finds an integer multiplier that lands the longest side as close to the target as possible within a band of 80%–160% of it, then resizes with nearest-neighbor. So a 200px image targeting 1024 scales by 5 → 1000px; a 300px one scales by 3 → 900px (3×300=900 is the closest integer multiple in the band). Output sizes are approximate, not exact - that's the design, and it's the right one for pixel art, because it guarantees the pixel blocks stay uniform instead of stretching to hit a magic number.

The crop_and_pad boolean (default off) is the "squared up" behavior. Turn it on and it does one of two things: for opaque images it center-crops each frame to a square (the size of the shorter side) before scaling; for transparent RGBA frames it finds the bounding box of the visible content across all frames, then pads each one into a square with a 15% margin - so an animated sprite with a transparent background comes out as centered squares with consistent padding instead of jumping around. That's a genuinely thoughtful detail for sprite work.

Inputs and outputs

  • image - the frame(s) to upscale.
  • target_resolution (INT, default 1024) - the approximate longest-side goal.
  • crop_and_pad (BOOLEAN, default false) - square-crop (opaque) or bbox-pad (transparent) before scaling.

Outputs: upscaled_img (the scaled result) and cropped_origin_img - the frame before upscaling, after any crop/pad. That second output is a great debugging tool: it shows exactly what the crop step ate, so you can see if you lost an arm before you blame the scaling.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/AhBumm/ComfyUI_UnfakePy_Warpper

or ComfyUI Manager → search ComfyUI_UnfakePy_Warpper, restart. Deps: unfake==1.0.7 + nest_asyncio (unfake pulls opencv, Pillow, NumPy; Python 3.10+). CPU, instant, no models.

When to use it

Reach for this when you need a batch of pixel frames at a consistent display size - which is most sprite pipelines. Watch out for the two traps: it's approximate, so don't wire it into something that needs exact 1024x1024 dimensions and then scratch your head at 1000 or 900; and crop_and_pad changes composition by center-cropping, so only enable it when you genuinely want squares. And like every node in this pack it's a resampler, not a restorer - clean up your pixel art with Unfake Pixelate Tools first, then size it with this.

CategoryBillBum/PixelTools

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
target_resolutionINT1024
crop_and_padBOOLEANfalse

Outputs (2)

NameTypeDescription
upscaled_imgIMAGE
cropped_origin_imgIMAGE