first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# Introduction
|
||||
GetFileNameFromURL is a ComfyUI custom node that extracts the filename from a URL. It can handle various URLs and is capable of handling redirects.
|
||||
<img width="1026" alt="image" src="https://github.com/githubYiheng/ComfyUI_GetFileNameFromURL/assets/5706385/29e33bea-cfb3-4b26-b481-c3c97f6556f4">
|
||||
|
||||
# Features
|
||||
Extracts filename from a URL
|
||||
Handles 303 redirects
|
||||
# Usage
|
||||
In your terminal, navigate to the custom_nodes directory of your ComfyUI installation.
|
||||
Clone this repository using the git clone command:
|
||||
```bash
|
||||
git clone https://github.com/your-username/your-repository.git
|
||||
```
|
||||
Restart ComfyUI.
|
||||
In ComfyUI, locate the "Get FileName From URL" node.
|
||||
Input the desired URL into the node's url field.
|
||||
Run the node, and it will output both the extracted filename and the original URL.
|
||||
# Inputs
|
||||
url (STRING): The URL from which to extract the filename.
|
||||
# Outputs
|
||||
filename (STRING): The extracted filename.
|
||||
url (STRING): The input URL.
|
||||
# Example
|
||||
## Input:
|
||||
* https://example.com/path/to/file.jpg
|
||||
|
||||
## Output:
|
||||
|
||||
* filename: file.jpg
|
||||
* url: https://example.com/path/to/file.jpg
|
||||
# Dependencies
|
||||
requests
|
||||
cgi
|
||||
@@ -0,0 +1,3 @@
|
||||
from .add_border_to_image import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
||||
|
||||
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
|
||||
@@ -0,0 +1,60 @@
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class ChangeImageBorder:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE", ),
|
||||
"value": ("INT", {"default": 0}),
|
||||
"border_size": ("INT", {"default": 2}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "change_border_to"
|
||||
CATEGORY = "Tools"
|
||||
|
||||
def change_border_to(image_path, value, border_size=2):
|
||||
# Open the image file
|
||||
with Image.open(image_path) as img:
|
||||
# Convert to RGBA if it's not already in this mode
|
||||
img = img.convert("RGBA")
|
||||
|
||||
# Get the image data
|
||||
data = np.array(img)
|
||||
|
||||
# Change the top and bottom border pixels
|
||||
data[:border_size, :] = [value, value, value, 255] # top
|
||||
data[-border_size:, :] = [value, value, value, 255] # bottom
|
||||
|
||||
# Change the left and right border pixels
|
||||
data[:, :border_size] = [value, value, value, 255] # left
|
||||
data[:, -border_size:] = [value, value, value, 255] # right
|
||||
|
||||
# Create a new image from the modified data
|
||||
new_img = Image.fromarray(data, mode='RGBA')
|
||||
|
||||
# Return the new image
|
||||
return new_img
|
||||
|
||||
# Set the web directory, any .js file in that directory will be loaded by the frontend as a frontend extension
|
||||
# WEB_DIRECTORY = "./somejs"
|
||||
|
||||
|
||||
# A dictionary that contains all nodes you want to export with their names
|
||||
# NOTE: names should be globally unique
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"ChangeImageBorder": ChangeImageBorder
|
||||
}
|
||||
|
||||
# A dictionary that contains the friendly/humanly readable titles for the nodes
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ChangeImageBorder": "Change Image Border"
|
||||
}
|
||||
Reference in New Issue
Block a user