Add custom nodes, Civitai loras (LFS), and vast.ai setup script
Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
93
custom_nodes/rgthree-comfy/py/image_inset_crop.py
Normal file
93
custom_nodes/rgthree-comfy/py/image_inset_crop.py
Normal file
@@ -0,0 +1,93 @@
|
||||
"""Image Inset Crop, with percentages."""
|
||||
from .log import log_node_info
|
||||
from .constants import get_category, get_name
|
||||
from nodes import MAX_RESOLUTION
|
||||
|
||||
|
||||
def get_new_bounds(width, height, left, right, top, bottom):
|
||||
"""Returns the new bounds for an image with inset crop data."""
|
||||
left = 0 + left
|
||||
right = width - right
|
||||
top = 0 + top
|
||||
bottom = height - bottom
|
||||
return (left, right, top, bottom)
|
||||
|
||||
|
||||
class RgthreeImageInsetCrop:
|
||||
"""Image Inset Crop, with percentages."""
|
||||
|
||||
NAME = get_name('Image Inset Crop')
|
||||
CATEGORY = get_category()
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls): # pylint: disable = invalid-name, missing-function-docstring
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"measurement": (['Pixels', 'Percentage'],),
|
||||
"left": ("INT", {
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": MAX_RESOLUTION,
|
||||
"step": 8
|
||||
}),
|
||||
"right": ("INT", {
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": MAX_RESOLUTION,
|
||||
"step": 8
|
||||
}),
|
||||
"top": ("INT", {
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": MAX_RESOLUTION,
|
||||
"step": 8
|
||||
}),
|
||||
"bottom": ("INT", {
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": MAX_RESOLUTION,
|
||||
"step": 8
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "crop"
|
||||
|
||||
# pylint: disable = too-many-arguments
|
||||
def crop(self, measurement, left, right, top, bottom, image=None):
|
||||
"""Does the crop."""
|
||||
|
||||
_, height, width, _ = image.shape
|
||||
|
||||
if measurement == 'Percentage':
|
||||
left = int(width - (width * (100 - left) / 100))
|
||||
right = int(width - (width * (100 - right) / 100))
|
||||
top = int(height - (height * (100 - top) / 100))
|
||||
bottom = int(height - (height * (100 - bottom) / 100))
|
||||
|
||||
# Snap to 8 pixels
|
||||
left = left // 8 * 8
|
||||
right = right // 8 * 8
|
||||
top = top // 8 * 8
|
||||
bottom = bottom // 8 * 8
|
||||
|
||||
if left == 0 and right == 0 and bottom == 0 and top == 0:
|
||||
return (image,)
|
||||
|
||||
inset_left, inset_right, inset_top, inset_bottom = get_new_bounds(width, height, left, right,
|
||||
top, bottom)
|
||||
if inset_top > inset_bottom:
|
||||
raise ValueError(
|
||||
f"Invalid cropping dimensions top ({inset_top}) exceeds bottom ({inset_bottom})")
|
||||
if inset_left > inset_right:
|
||||
raise ValueError(
|
||||
f"Invalid cropping dimensions left ({inset_left}) exceeds right ({inset_right})")
|
||||
|
||||
log_node_info(
|
||||
self.NAME, f'Cropping image {width}x{height} width inset by {inset_left},{inset_right}, ' +
|
||||
f'and height inset by {inset_top}, {inset_bottom}')
|
||||
image = image[:, inset_top:inset_bottom, inset_left:inset_right, :]
|
||||
|
||||
return (image,)
|
||||
Reference in New Issue
Block a user