LoadImage silently returns a crop for HEIC/HEIF images after #13594 switched to pyav
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Expected Behavior
Before PR #13594, `LoadImage` used `Pillow` directly; for `HEIC` files without `pillow-heif` installed (which is not included in [requirements.txt](https://github.com/Comfy-Org/ComfyUI/blob/master/requirements.txt)), it raised `UnidentifiedImageError`. The expected behavior after #13594 should be the same as for any other unsupported format: **either load it correctly, or fail explicitly with an error.**
### Actual Behavior
After #13594, `LoadImage` silently returns a 512×512 crop of the top-left corner of the image. **The workflow completes without any error or warning, giving the user no indication that the full image was not loaded.** This affects both `.heic` files and `HEIC` files saved with a `.jpg` extension, which is common for photos shared from iPhone.
### Steps to Reproduce
1. Take any `HEIC` photo from an iPhone (either a `.heic` file or a `.jpg` file that is actually `HEIC`; both are common when sharing photos from iOS).
2. Upload it to ComfyUI's `LoadImage` node.
3. Preview the input image.
### Other
`HEIC` images from iPhone are stored as a grid of 512×512 tiles, each encoded as a separate video stream inside the file container. `pyav`, being a video library, sees these as independent video streams and returns only the first one, a 512×512 tile.
Before #13594 this was harmless because `LoadImage` used `Pillow`, which doesn't understand the format and fails clearly. After #13594, `pyav` runs first and returns the first tile as a valid non-empty image, so the `Pillow` fallback never triggers. The result is a 512×512 crop returned silently as if it were the full image.
`LoadImage` is probably the most basic and important node in any ComfyUI workflow, so I think changes to it deserve extra care. I don't see a straightforward fix, since this issue is not solely about `HEIC`, and other formats with similar container structures (like `AVIF`) may be affected too. Assuming we agree that silently returning a partial image is worse than an explicit error, any solution would require identifying each affected format and either failing clearly or handling it correctly. Given the scope, I'd suggest a broader discussion before settling on an approach.
### Debug Logs
```powershell
python main.py --gpu-only
setup plugin alembic.autogenerate.schemas
setup plugin alembic.autogenerate.tables
setup plugin alembic.autogenerate.types
setup plugin alembic.autogenerate.constraints
setup plugin alembic.autogenerate.defaults
setup plugin alembic.autogenerate.comments
WARNING: You need pytorch with cu130 or higher to use optimized CUDA operations.
Found comfy_kitchen backend triton: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8']}
Found comfy_kitchen backend eager: {'available': True, 'disabled': False, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'dequantize_mxfp8', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'scaled_mm_mxfp8', 'scaled_mm_nvfp4']}
Found comfy_kitchen backend cuda: {'available': True, 'disabled': True, 'unavailable_reason': None, 'capabilities': ['apply_rope', 'apply_rope1', 'dequantize_nvfp4', 'dequantize_per_tensor_fp8', 'quantize_mxfp8', 'quantize_nvfp4', 'quantize_per_tensor_fp8', 'scaled_mm_nvfp4']}
Checkpoint files will always be loaded safely.
Total VRAM 81079 MB, total RAM 1886811 MB
pytorch version: 2.9.1+cu128
Set vram state to: HIGH_VRAM
Device: cuda:0 NVIDIA H100 80GB HBM3 : cudaMallocAsync
Using async weight offloading with 2 streams
Enabled pinned memory 1698130.0
working around nvidia conv3d memory bug.
Using pytorch attention
Python version: 3.12.9 (main, Mar 11 2025, 17:26:57) [Clang 20.1.0 ]
ComfyUI version: 0.20.1
comfy-aimdo version: 0.3.0
comfy-kitchen version: 0.2.8
ComfyUI frontend version: 1.43.17
[Prompt Server] web root: /home/user/ComfyUI_Upstream/.venv/lib/python3.12/site-packages/comfyui_frontend_package/static
Asset seeder disabled
Import times for custom nodes:
0.0 seconds: /home/user/ComfyUI_Upstream/custom_nodes/websocket_image_save.py
0.0 seconds: /home/user/ComfyUI_Upstream/custom_nodes/ComfyUI-KJNodes
Context impl SQLiteImpl.
Will assume non-transactional DDL.
Starting server
To see the GUI go to: http://127.0.0.1:8188
```
Contributor guide
Assessment
This issue has not been assessed yet.