Nodes/ComfyUI Essentials/πŸ”§ Image Seam Carving
ComfyUI Node Runs on cloud

πŸ”§ Image Seam Carving

Content-aware resize that doesn't just crop or squish

By cubiqΒ·Created 3 years agoΒ·Updated about a year agoΒ· 1,160
πŸ”§ Image Seam Carving
  • image
  • keep_mask
  • drop_mask
  • IMAGE
β—„width512β–Ί
β—„height512β–Ί
β—„energyβ–Ύβ–Ί
β—„orderβ–Ύβ–Ί

A normal resize gives you two bad options when the aspect ratio changes: crop (lose whatever's at the edges) or stretch (distort everything uniformly, faces included). Image Seam Carving does the thing Photoshop calls "content-aware scale" - it finds and removes (or duplicates) the least visually important paths running through the image, one at a time, so it can change the aspect ratio while keeping important content close to its original size and squeezing the boring parts - sky, plain walls, empty floor - instead.

How it works

width and height (1–16,384 each) set your target output size. energy picks how the algorithm measures which pixels matter: backward looks at gradients in the original image; forward also accounts for the new seams the carving process itself introduces as it goes, which generally produces fewer artifacts on aggressive resizes at the cost of more compute. order decides whether it carves width-first or height-first when both dimensions need to change - this matters because carving one axis changes the energy map the other axis sees.

Two optional inputs give you manual control over what survives: keep_mask protects a region from ever being carved through, and drop_mask marks a region for preferential removal, so the algorithm eats seams through it first.

Inputs and outputs

Required: image, width, height, energy (backward / forward), order (width-first / height-first). Optional: keep_mask, drop_mask. Output: IMAGE.

Installing it

Via ComfyUI Manager, search "ComfyUI Essentials". Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cubiq/ComfyUI_essentials

Restart. Maintenance-only pack since April 2025.

Common issues & troubleshooting

Visible warping on a big resize. This works best when there's genuine low-importance content for it to eat into - sky, plain background, empty floor. If your whole frame is "important" (a tight crop on a busy scene, a dense composition), there's nowhere low-energy to cut and you'll see artifacts no matter how you tune it. That's the algorithm working as designed on a bad-fit image, not a bug.

A face or subject got distorted. Use keep_mask proactively, before the carve, rather than trying to fix warping after the fact - protecting a region up front is far more reliable than any post-hoc correction.

It's noticeably slower than a normal resize node. That's expected - it's solving for a seam through the whole image, potentially many times over for a large size change, which is genuinely more compute than a straight scale. Don't drop this into a batch or per-frame video loop expecting resize-node speed; budget for it being meaningfully slower.

Categoryessentials/image manipulation

Inputs (7)

NameTypeDefaultDescription
imageIMAGEβ€”
widthINT5121–16384β€”
heightINT5121–16384β€”
energyCOMBO2 options: backward, forward
orderCOMBO2 options: width-first, height-first
keep_maskoptMASKβ€”
drop_maskoptMASKβ€”

Outputs (1)

NameTypeDescription
IMAGEIMAGEβ€”