Skip to content

Commit dae3d34

Browse files
Use pyav to load images instead of pillow. (#13594)
On failure (ex: animated webp files) fallback to old pillow code. This should fix the extra precision in high bit depth images (like 16 bit PNG) being discarded when loaded by Pillow and potentially add support for more image formats.
1 parent c7a517c commit dae3d34

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

nodes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from comfy.comfy_types import IO, ComfyNodeABC, InputTypeDict, FileLocator
3333
from comfy_api.internal import register_versions, ComfyAPIWithVersion
3434
from comfy_api.version_list import supported_versions
35-
from comfy_api.latest import io, ComfyExtension
35+
from comfy_api.latest import io, ComfyExtension, InputImpl
3636

3737
import comfy.clip_vision
3838

@@ -1716,6 +1716,10 @@ def INPUT_TYPES(s):
17161716
def load_image(self, image):
17171717
image_path = folder_paths.get_annotated_filepath(image)
17181718

1719+
components = InputImpl.VideoFromFile(image_path).get_components()
1720+
if components.images.shape[0] > 0:
1721+
return (components.images, 1.0 - components.alpha[..., -1] if components.alpha is not None else torch.zeros((components.images.shape[0], 64, 64), dtype=torch.float32, device="cpu"))
1722+
17191723
img = node_helpers.pillow(Image.open, image_path)
17201724

17211725
output_images = []

0 commit comments

Comments
 (0)