After launching ComfyUI for a while, the "Load Image" node cannot identify WebP.
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 155
Description
### Expected Behavior
"Load Image" can support various common formats, such as jpeg, png, webp
### Actual Behavior
When loading a webp format image, an error message appears, indicating that the image cannot be recognized. In fact, the image is normal.
```
[2024-07-10 11:34] got prompt
[2024-07-10 11:34] [rgthree] Using rgthree's optimized recursive execution.
[2024-07-10 11:34] !!! Exception during processing!!! local variable 'x' referenced before assignment
[2024-07-10 11:34] Traceback (most recent call last):
File "/root/work_py/ComfyUI/node_helpers.py", line 16, in pillow
x = fn(arg)
File "/root/.conda/envs/comfyui/lib/python3.10/site-packages/PIL/Image.py", line 3298, in open
elif hasattr(obj, "tostring"):
PIL.UnidentifiedImageError: cannot identify image file '/root/work_py/ComfyUI/input/abc.webp'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/work_py/ComfyUI/node_helpers.py", line 20, in pillow
x = fn(arg)
File "/root/.conda/envs/comfyui/lib/python3.10/site-packages/PIL/Image.py", line 3298, in open
elif hasattr(obj, "tostring"):
PIL.UnidentifiedImageError: cannot identify image file '/root/work_py/ComfyUI/input/abc.webp'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/work_py/ComfyUI/execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "/root/work_py/ComfyUI/execution.py", line 81, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "/root/work_py/ComfyUI/execution.py", line 74, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "/root/work_py/ComfyUI/nodes.py", line 1462, in load_image
img = node_helpers.pillow(Image.open, image_path)
File "/root/work_py/ComfyUI/node_helpers.py", line 24, in pillow
return x
UnboundLocalError: local variable 'x' referenced before assignment
[2024-07-10 11:34] Prompt executed in 0.04 seconds
```
### Steps to Reproduce
webp img:
workflow: [workflow.json](https://github.com/user-attachments/files/16154905/workflow.json)
example

- Load workflow
- ”Load image“ Upload a Webp image
- Click "Queue Prompt"
### Debug Logs
```powershell
System Info:
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.118.1.el7.x86_64
Architecture: x86-64
```
```
Python Env Info:
Python Env: Python 3.10.6
pillow==10.4.0
```
```
Python 3.10.6 (main, Oct 24 2022, 16:07:47) [GCC 11.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.25.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from PIL import features
...: print (features.check_module('webp'))
True
```
```
### Other
When the service is just started, it can parse the Webp format. After running for a while, it cannot parse Webp. Other image formats are normal. After restarting ComfyUI, it returns to normal. The image with the error can be loaded normally by executing PIL.Image.Open("abc.webp") in the terminal.
Contributor guide
Assessment
This issue has not been assessed yet.