π Bitmap Crop Center
Crop a bitmap to its middle without doing the math yourself
- BITMAP
- BITMAP
Center crop is one of those things that sounds too boring to be useful until you need it. You render a shape grid at 512Γ512, then realize the interesting part of the composition is the middle third, and you'd rather hand ControlNet a tighter guide so the model spends its latent budget on the important area instead of a bunch of empty border. Bitmap Crop Center is exactly that: chop a bitmap down to its center, by fraction or by pixel count.
It's part of the Dream Painter pack's bitmap-processing shelf, which reads like a tiny image toolbox: resize, rotate, expand canvas, invert, edge detect. This one sits next to Resize because you'll frequently crop-and-resize in sequence to re-frame a guide.
How it works
The node takes the bitmap's current size and works out the new width and height from your inputs, then slices out the center rectangle - the crop offsets are computed as half the difference on each side, so the removed pixels come off both edges symmetrically. Whatever you shave off, the bitmap that comes out is still one-bit (mode "1"), just smaller.
The subtle bit is how the two sizing paths interact:
- width_pixels / height_pixels - exact target size in pixels. Set these for a precise crop.
- width_multiplier / height_multiplier - a fraction of the current size (0 to 1). 0.5 crops to half the width.
Both default to 0, and 0 means "ignore me, use the other one." Leave both at 0 on an axis and that axis stays uncropped. The node also clamps so you can't crop to larger than the source, and anything that computes to under 1 pixel just keeps the original.
Inputs and outputs
- BITMAP - the bitmap to crop.
- width_multiplier, width_pixels, height_multiplier, height_pixels - the four sizing inputs above.
Output is a single BITMAP. As with every bitmap node in this pack, wire it into Bitmap To Image & Mask before it can reach a ControlNet, a mask input, or a preview.
Installing
ComfyUI Manager β Install Custom Nodes β search Dream Painter β install β restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/alt-key-project/comfyui-dream-painter
cd comfyui-dream-painter
pip install -r requirements.txt
No models to download - the whole pack is PIL pixel math.
Common issues
The most common gotcha is expecting both pixel and multiplier inputs to compose (e.g. "crop to half of half"). They don't - a nonzero pixel value always wins for that axis. Also remember the output keeps the bitmap's size but not its absolute position: if you later feed the cropped guide into a ControlNet that expects full-canvas coordinates, the crop will sit in the corner, not in the center, because the bitmap no longer has any memory of where it lived on the original canvas. Center-crop, then reposition or re-pad if the downstream node cares about placement.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| BITMAP | BITMAP | β | |
| width_multiplier | FLOAT | 0.0000β1 | β |
| width_pixels | INT | 0 | β |
| height_multiplier | FLOAT | 0.0000β1 | β |
| height_pixels | INT | 0 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BITMAP | BITMAP | β |