Support resizing for all both dimensions

This commit is contained in:
ProGamerGov
2025-02-02 09:55:13 -07:00
parent eaac40666b
commit 4fafe97198
2 changed files with 11 additions and 11 deletions
+10 -10
View File
@@ -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()
+1 -1
View File
@@ -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 = [""]