From 685702789530243a4f955b3d0fb63e5e4e9571ab Mon Sep 17 00:00:00 2001 From: Chengwei Ouyang Date: Mon, 8 Dec 2025 17:02:23 +0800 Subject: [PATCH] fix: handle PNG files with MPO metadata in input image processing --- comfy-nodes/input_image.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/comfy-nodes/input_image.py b/comfy-nodes/input_image.py index 3399a4f..25747ae 100755 --- a/comfy-nodes/input_image.py +++ b/comfy-nodes/input_image.py @@ -101,8 +101,17 @@ class ShellAgentPluginInputImage: w, h = None, None excluded_formats = ['MPO'] - - for i in ImageSequence.Iterator(img): + + # Determine frames to process + # Some PNG files contain MPO EXIF metadata causing PIL to misidentify them as MPO + # When this happens, ImageSequence.Iterator fails with "not a JPEG file" + try: + frames = list(ImageSequence.Iterator(img)) + except SyntaxError: + # Fallback for misidentified formats (e.g., PNG with MPO metadata) + frames = [img] + + for i in frames: i = node_helpers.pillow(ImageOps.exif_transpose, i) if i.mode == 'I':