diff --git a/nodes.py b/nodes.py index a152276..31c0713 100644 --- a/nodes.py +++ b/nodes.py @@ -31,8 +31,8 @@ class PanoramaViewerNode: Returns: dict: Dictionary containing required input parameters: - images (torch.Tensor): Input tensor containing the panoramic image. - - max_width (int): Maximum width for resizing. Default: 4096. - Set to -1 for no resizing. Supports 2:1 and 1:1 aspect ratios. + - max_width (int): Maximum dimension for resizing. Default: 4096 + Set to -1 for no resizing. """ return { "required": { @@ -43,8 +43,7 @@ class PanoramaViewerNode: "default": 4096, "tooltip": "The max width to use. Images larger than the" + " specified value will be resized. Larger sizes may run" - + " slower. Set to -1 for no resizing. Currently only 2:1" - + " and 1:1 aspect ratios are supported for resizing.", + + " slower. Set to -1 for no resizing.", }, ), } @@ -103,12 +102,13 @@ class PanoramaViewerNode: pil_image = Image.fromarray(image_np) # Optionally resize image - if max_width > 0 and pil_image.size[0] > max_width: - if pil_image.size[0] == pil_image.size[1]: - new_size = (max_width, max_width) - else: - new_size = (max_width, max_width // 2) - pil_image = pil_image.resize(new_size, resample=Image.Resampling.LANCZOS) + if max_width > 0 and ( + pil_image.size[0] > max_width or pil_image.size[1] > max_width + ): + new_size = tuple( + [int(max_width * x / max(pil_image.size)) for x in pil_image.size] + ) + pil_image = pil_image.resize(new_size, resample=Image.Resampling.LANCZOS) # type: ignore[arg-type] # Save to BytesIO buffered = BytesIO() diff --git a/pyproject.toml b/pyproject.toml index 7e65381..d260ccb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-preview360panorama" description = "A custom ComfyUI node for interactive 360° panorama image previews. Panoramic 360 images are also sometimes known as VR photography (virtual reality), HDRI environments (ex: skyboxes), image spheres, spherical images, 360 pano, and 360 degree photos." -version = "1.0.0" +version = "1.0.1" license = {file = "LICENSE"} dependencies = [""]