Nodes/ComfyUI-SC-PhotoDoodle/照片涂鸦裁切
ComfyUI Node

照片涂鸦裁切

The boring crop node that stops your doodle from silently breaking the graph

By latentcat·Created about a year ago·Updated about a year ago· 30
照片涂鸦裁切
  • image
  • IMAGE
width512
height512

If you've grabbed a PhotoDoodle workflow and seen this node sitting between LoadImage and VAEEncode, here's the whole story: PhotoDoodleCrop forces whatever image you feed it - usually your doodle - to exactly width × height, so it lines up with the empty latent the sampler generates into. That's it. It's a small node that exists to prevent one genuinely annoying class of bug, and it does the job well.

Why it exists: PhotoDoodle sampling works by VAE-encoding your sketch and handing those tokens to the sampler alongside an empty latent canvas (see PhotoDoodleSamplerAdvanced in this pack). If the sketch's dimensions don't match the canvas, that conditioning goes wrong - not with an error, just with output that quietly ignores or mangles your drawing. The README is blunt about the alternative: skip this node and you must make sure your input image dimensions match the empty latent's yourself. This node does that matching for you.

How it works, straight from the source: it compares your image's aspect ratio to the target width/height. If the image is wider than the target, it crops the left and right edges symmetrically (a center crop); if it's taller, it crops top and bottom. Then it resizes the result to exactly width × height with Lanczos. So a portrait photo dropped into a 512×768 target keeps its content, just trimmed to fit, and even a small doodle gets scaled up to fill the whole canvas. No stretching, no letterboxing, no black bars.

The inputs you actually touch:

  • width / height - the target size, default 512, stepping by 8. Keep these in sync with your EmptySD3LatentImage; the sampler compares against that canvas, not against what this node thinks.
  • image - the doodle or reference photo.

Output: a single IMAGE at exactly width × height, ready to feed VAEEncode and then the sampler's condition_image.

Install is the same as the rest of the pack: search ComfyUI-SC-PhotoDoodle in ComfyUI Manager, or

cd ComfyUI/custom_nodes
git clone https://github.com/latentcat/ComfyUI-SC-PhotoDoodle

then restart ComfyUI. Note the README's own install snippet has a placeholder your-username URL - the real repo is latentcat/ComfyUI-SC-PhotoDoodle. No extra pip dependencies; the pack is just these three nodes plus a startup script.

Where people get tripped up:

  • It center-crops. If you drew on the far edge of your photo, the crop can cut the interesting part off. For a doodle that's usually fine; for a reference photo with a subject at the edge, check the crop before blaming the sampler.
  • Stick to multiples of 8. Flux latents run at 1/8 resolution, and the step of 8 on both fields is there for a reason. Odd sizes mean needless pain downstream.
  • It resizes up as happily as it resizes down, so a low-res doodle gets scaled to whatever you asked for. If that looks mushy, the fix is a bigger source image, not this node.

It won't win any awards for cleverness, but in a workflow where a one-pixel mismatch can silently wreck your edit, a node that guarantees the match is the one you actually reach for.

Categoryimage/processing

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
widthINT51264–8192
heightINT51264–8192

Outputs (1)

NameTypeDescription
IMAGEIMAGE