Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
8a451234
Commit
8a451234
authored
Nov 18, 2023
by
comfyanonymous
Browse files
Add ImageCrop node.
parent
0cf4e869
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
comfy_extras/nodes_images.py
comfy_extras/nodes_images.py
+29
-0
nodes.py
nodes.py
+1
-0
No files found.
comfy_extras/nodes_images.py
0 → 100644
View file @
8a451234
import
nodes
MAX_RESOLUTION
=
nodes
.
MAX_RESOLUTION
class
ImageCrop
:
@
classmethod
def
INPUT_TYPES
(
s
):
return
{
"required"
:
{
"image"
:
(
"IMAGE"
,),
"width"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
1
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"height"
:
(
"INT"
,
{
"default"
:
512
,
"min"
:
1
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"x"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
"y"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
MAX_RESOLUTION
,
"step"
:
1
}),
}}
RETURN_TYPES
=
(
"IMAGE"
,)
FUNCTION
=
"crop"
CATEGORY
=
"image/transform"
def
crop
(
self
,
image
,
width
,
height
,
x
,
y
):
x
=
min
(
x
,
image
.
shape
[
2
]
-
1
)
y
=
min
(
y
,
image
.
shape
[
1
]
-
1
)
to_x
=
width
+
x
to_y
=
height
+
y
img
=
image
[:,
y
:
to_y
,
x
:
to_x
,
:]
return
(
img
,)
NODE_CLASS_MAPPINGS
=
{
"ImageCrop"
:
ImageCrop
,
}
nodes.py
View file @
8a451234
...
...
@@ -1800,6 +1800,7 @@ def init_custom_nodes():
"nodes_hypertile.py"
,
"nodes_model_advanced.py"
,
"nodes_model_downscale.py"
,
"nodes_images.py"
,
]
for
node_file
in
extras_files
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment