mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-21 12:42:11 -03:00
v0.12
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 🔗 Comfyui : Bjornulf_custom_nodes v0.11 🔗
|
||||
# 🔗 Comfyui : Bjornulf_custom_nodes v0.12 🔗
|
||||
|
||||
# Dependencies
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
- **v0.9**: Add a new node : Return one random line from input.
|
||||
- **v0.10**: Add a new node : Loop (All Lines from input) - Iterate over all lines from an input text.
|
||||
- **v0.11**: Add a new node : Text with random Seed - Generate a random seed, along with text.
|
||||
- **v0.12**: Combine images : Add option to move vertically and horizontally. (from -50% to 150%)
|
||||
|
||||
# 📝 Nodes descriptions
|
||||
|
||||
@@ -172,8 +173,8 @@ But you can sometimes also want a black and white image...
|
||||

|
||||
|
||||
**Description:**
|
||||
Combine two images into a single image : a background and one (or several) transparent overlay. (allow for video frames.)
|
||||
Update 0.8 : Also have a option to put image top, bottom or center.
|
||||
Combine two images into a single image : a background and one (or several) transparent overlay. (allow to have a video there, just send all the frames and recombine them after.)
|
||||
Update 0.11 : Add option to move vertically and horizontally. (from -50% to 150%)
|
||||
❗ Warning : For now, `background` is a static image. (I will allow video there later too.)
|
||||
|
||||
## 25 - 🟩➜▢ Green Screen to Transparency
|
||||
|
||||
@@ -9,7 +9,8 @@ class CombineBackgroundOverlay:
|
||||
"required": {
|
||||
"background": ("IMAGE",),
|
||||
"overlay_alpha": ("IMAGE",),
|
||||
"position": (["middle", "top", "bottom"],),
|
||||
"horizontal_position": ("FLOAT", {"default": 50, "min": -50, "max": 150, "step": 0.1}),
|
||||
"vertical_position": ("FLOAT", {"default": 50, "min": -50, "max": 150, "step": 0.1}),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -17,7 +18,7 @@ class CombineBackgroundOverlay:
|
||||
FUNCTION = "combine_background_overlay"
|
||||
CATEGORY = "Bjornulf"
|
||||
|
||||
def combine_background_overlay(self, background, overlay_alpha, position):
|
||||
def combine_background_overlay(self, background, overlay_alpha, horizontal_position, vertical_position):
|
||||
# Convert background from torch tensor to numpy array
|
||||
bg = background[0].numpy()
|
||||
bg = (bg * 255).astype(np.uint8)
|
||||
@@ -37,14 +38,11 @@ class CombineBackgroundOverlay:
|
||||
ov_img = Image.fromarray(ov, 'RGB')
|
||||
ov_img = ov_img.convert('RGBA')
|
||||
|
||||
# Calculate position based on user selection
|
||||
x = (bg_img.width - ov_img.width) // 2
|
||||
if position == "middle":
|
||||
y = (bg_img.height - ov_img.height) // 2
|
||||
elif position == "top":
|
||||
y = 0
|
||||
else: # bottom
|
||||
y = bg_img.height - ov_img.height
|
||||
# Calculate horizontal position
|
||||
x = int((horizontal_position / 100) * (bg_img.width - ov_img.width))
|
||||
|
||||
# Calculate vertical position
|
||||
y = int((vertical_position / 100) * (bg_img.height - ov_img.height))
|
||||
|
||||
# Create a new image for this overlay
|
||||
result = Image.new('RGBA', bg_img.size, (0, 0, 0, 0))
|
||||
@@ -52,7 +50,7 @@ class CombineBackgroundOverlay:
|
||||
# Paste the background
|
||||
result.paste(bg_img, (0, 0))
|
||||
|
||||
# Paste the overlay in the selected position
|
||||
# Paste the overlay in the calculated position
|
||||
result.paste(ov_img, (x, y), ov_img)
|
||||
|
||||
# Convert back to numpy array and then to torch tensor
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 631 KiB After Width: | Height: | Size: 597 KiB |
Reference in New Issue
Block a user