Nodes/WAS Node Suite v3/Crop Data to Numbers
ComfyUI Node Runs on cloud

Crop Data to Numbers

A crop window, opened up into plain pixel numbers

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Crop Data to Numbers
  • crop_data
  • crop_width
  • crop_height
  • x
  • y
  • width
  • height
  • summary

When a WAS Suite crop node hands you a crop_data, you're getting a rectangle as an opaque value - great for round-tripping a crop, useless if you actually want to do math on it. This node opens that window up into the raw integers: where it starts in the source image, how far it runs, and what size picture the crop node emitted. Seven outputs, all numbers (plus one convenience string), nothing fancy.

Reach for it when you need to place something back at the same spot - a paste, a label, a mask, a second crop at matching coordinates - or when you want to write the window out as text. The sibling node Crop Data to Bounds converts the same window into a bounds row if what you're feeding speaks bounds; choose based on where the numbers are going.

The outputs, and which ones you actually set

There are no inputs to set beyond the crop_data itself, so this is a pure "unpack" node. What you get:

  • crop_width / crop_height - the size of the picture the crop node emitted, in pixels. This is what a resize must match if you reworked the crop and want to put it back cleanly.
  • x / y - the left and top edges of the window in the source image, counting from 0. 100 means the window starts 100 pixels in from the left.
  • width / height - how far the window runs across and down the source: its right edge minus x. Add them to x/y and you have the right and bottom edges.
  • summary - the whole window on one line (crop 480x480 at (100, 40) to (580, 500), 480x460), for a filename, a note, or Text to Console.

Wire x and y into a draw node to mark the same spot, or into a paste's placement so the result lands exactly where the crop was taken. Pair crop_width/crop_height with an Image Resize to bring a reworked region back to its original size before Image Paste Crop stitches it home.

Where the face crops make it weird

Same wrinkle as its sibling converter, worth repeating because it's the only part of this node that will ever bite: for every crop node except the two face croppers, crop_width/crop_height equal width/height. Image Crop Face and Image Crop Face (YuNet) square their window up - a 480×460 rectangle comes out as a 480×480 image - so there the two pairs diverge. That's by design: crop_width describes the file you actually got, width describes the rectangle you cut. Compare them and you can see exactly how much padding a face crop added.

The genuine failure mode: when a face crop finds nothing it passes False, and this node raises because there are no numbers to read. If a face can genuinely be absent in your workflow, guard the path before it reaches here.

Installing it

Standard WAS Node Suite v3 install - ComfyUI Manager, search WAS Node Suite v3, or clone the repo into custom_nodes and restart. No models, no extra packages, pure CPU-friendly arithmetic on the wire.

If you're ever unsure which numbers a crop node produced, drop this in and read the summary output - it's the entire window on one line, which is also exactly the string you'd want in a log or a saved filename.

CategoryWAS Suite/Image/Bound

Inputs (1)

NameTypeDefaultDescription
crop_dataCROP_DATAThe crop window to read, from any node with a crop_data output. Image Crop Face and Image Crop Face (YuNet) pass False here when they found no face, and that raises, since there are no numbers to read.

Outputs (7)

NameTypeDescription
crop_widthINTWidth of the picture the crop node emitted, in pixels. It matches width for every crop node but Image Crop Face and Image Crop Face (YuNet), which square their window up: a 480x460 window comes out 480x480. Wire it wherever a resize has to match what was cut.
crop_heightINTHeight of the picture the crop node emitted, in pixels. It parts from height only for the two face crops, for the same reason crop_width does. Pair the two to resize a reworked region back before Image Paste Crop puts it home.
xINTLeft edge of the window in the source image, counting from 0. 100 = the window starts 100 pixels in from the left. Feed it to Image Crop Location's left, or to a draw node marking the same spot.
yINTTop edge of the window in the source image, counting from 0. 40 = the window starts 40 pixels down. Pair it with x to place text, a paste or a mask exactly where the crop was taken from.
widthINTHow far the window runs across, in pixels: its right edge minus x. Add it to x for the right edge Image Crop Location asks for. This is the rectangle cut from the source, which crop_width matches unless a face crop squared it up.
heightINTHow far the window runs down, in pixels: its bottom edge minus y. Add it to y for the bottom edge. Compare it with crop_height to see how much a face crop padded the window on the way out.
summarySTRINGThe whole window on one line, as `crop 480x480 at (100, 40) to (580, 500), 480x460`, for a filename, a note or Text to Console.