commit b618225d5dd2c5dd086d48b6546bafd3881ce7af Author: jstit Date: Tue Aug 13 16:19:15 2024 +0700 first commit diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..6b3f3a7 --- /dev/null +++ b/__init__.py @@ -0,0 +1,7 @@ +from .nodes import ( + image_crop_circle, +) + +NODE_CLASS_MAPPINGS = { + **image_crop_circle.NODE_CLASS_MAPPINGS, +} diff --git a/nodes/image_crop_circle.py b/nodes/image_crop_circle.py new file mode 100644 index 0000000..119086a --- /dev/null +++ b/nodes/image_crop_circle.py @@ -0,0 +1,39 @@ +import numpy as np +from PIL import Image, ImageDraw + + +class ImageCropCircle: + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "image": ("IMAGE",), + } + } + + RETURN_TYPES = ("IMAGE",) + FUNCTION = "crop_circle" + + CATEGORY = "image/crop" + + def crop_circle(self, image): + size = min(image.size) + mask = Image.new("L", (size, size), 0) + draw = ImageDraw.Draw(mask) + draw.ellipse((0, 0, size, size), fill=255) + result = Image.new("RGBA", (size, size)) + result.paste(image, (0, 0), mask) + return (result,) + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "ImageCropCircle": ImageCropCircle, +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "ImageCropCircle": "ImageCropCircle", +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..04747c1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +diffusers +tqdm +boto3 \ No newline at end of file