Load Image node: unwanted silent compression applied to image output on masking
- 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
Input image maintains it's original quality after masking, as there is no reason for it to be recompressed upon masking when the original image is already available in the `input` folder.
### Actual Behavior
Input image, despite being a PNG both within `input\` and `input\clipspace`, the image in `input\clipspace` will inexplicably gain visible compression artifacts. The `clipspace-painted-` file within `input\clipspace` will suddenly have compression added to it, which will then poison every step relying on the `image` output of the `Load Image` node with a mask applied. This also causes unnecessary data duplication, as the source image will already be present in it's original condition within either the `input` folder or the `input\pasted` subfolder.
### Steps to Reproduce
Create a set of two simple chains of "Load Image" and "Preview Image" nodes. Add any mask to the second one. Run the workflow.
[Unwanted compression.json](https://github.com/user-attachments/files/26928433/Unwanted.compression.json)
### Debug Logs
```powershell
d:\programs\ComfyUI>.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build --listen --use-sage-attention --disable-api-nodes --fast fp16_accumulation --disable-all-custom-nodes
Adding extra search path checkpoints D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\Stable-diffusion
Adding extra search path configs D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\Stable-diffusion
Adding extra search path vae D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\VAE
Adding extra search path loras D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\Lora
Adding extra search path loras D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\LyCORIS
Adding extra search path upscale_models D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\ESRGAN
Adding extra search path upscale_models D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\RealESRGAN
Adding extra search path upscale_models D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\SwinIR
Adding extra search path embeddings D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\embeddings
Adding extra search path hypernetworks D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\hypernetworks
Adding extra search path controlnet D:\Programs\ComfyUI\ComfyUI\path\to\stable-diffusion-webui\models\ControlNet
Adding extra search path checkpoints D:\Models\checkpoints
Adding extra search path clip D:\Models\clip
Adding extra search path clip_vision D:\Models\clip_vision
Adding extra search path configs D:\Models\configs
Adding extra search path controlnet D:\Models\controlnet
Adding extra search path diffusion_models D:\Models\diffusion_models
Adding extra search path diffusion_models D:\Models\unet
Adding extra search path embeddings D:\Models\embeddings
Adding extra search path loras D:\Models\loras
Adding extra search path upscale_models D:\Models\upscale_models
Adding extra search path vae D:\Models\vae
d:\programs\ComfyUI\python_embeded\Lib\site-packages\torch\cuda\__init__.py:65: FutureWarning: The pynvml package is deprecated. Please install nvidia-ml-py instead. If you did not install pynvml directly, please report this to the maintainers of the package that installed pynvml for you.
import pynvml # type: ignore[import]
Found comfy_kitchen backend cuda: {'available': True, 'disabled': False, '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']}
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 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']}
Checkpoint files will always be loaded safely.
Total VRAM 24576 MB, total RAM 65367 MB
pytorch version: 2.10.0+cu130
xformers version: 0.0.35
Enabled fp16 accumulation.
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3090 : cudaMallocAsync
Using async weight offloading with 2 streams
Enabled pinned memory 26146.0
working around nvidia conv3d memory bug.
Using sage attention
d:\programs\ComfyUI\python_embeded\Lib\site-packages\requests\__init__.py:113: RequestsDependencyWarning: urllib3 (2.6.3) or chardet (7.3.0)/charset_normalizer (3.4.5) doesn't match a supported version!
warnings.warn(
aimdo: src-win/cuda-detour.c:77:INFO:aimdo_setup_hooks: found driver at 00007FFDD0ED0000, installing 4 hooks
aimdo: src-win/cuda-detour.c:61:DEBUG:install_hook_entrys: hooks successfully installed
aimdo: src/control.c:69:INFO:comfy-aimdo inited for GPU: NVIDIA GeForce RTX 3090 (VRAM: 24575 MB)
DynamicVRAM support detected and enabled
Python version: 3.13.11 (tags/v3.13.11:6278944, Dec 5 2025, 16:26:58) [MSC v.1944 64 bit (AMD64)]
ComfyUI version: 0.19.3
comfy-aimdo version: 0.2.12
comfy-kitchen version: 0.2.8
ComfyUI frontend version: 1.42.11
[Prompt Server] web root: d:\programs\ComfyUI\python_embeded\Lib\site-packages\comfyui_frontend_package\static
Asset seeder disabled
Skipping loading of custom nodes
Context impl SQLiteImpl.
Will assume non-transactional DDL.
Starting server
```
### Other
This is a fundamental flaw breaking inpainting workflows, as due to the way inpainting workflows work in Comfy, the more compression there will be the more inpainting iterations are done, causing more damage to the final result the more one tries to improve it. As is the case with compression artifacts, they are the most evident on red images. It's possible that thousands of images ended up getting silent compression applied to them due to this bug.
The easy fix is to simplify the way clipspace masking images are made so that the unmasked image that is then passed to the `image` input is simply a direct copy of the input file. Remove the useless silent compression code. The proper fix would be redoing the way clipspace masking works so that it only needs to create the mask images while referring to the original files directly, as these will always be taken somewhere from the `input` folder so there's no point in duplicating them with every masking operation to begin with.
As a fun fact, `example.png` with the silent compression from the `\clipspace` subfolder ends up weighing more than the original input. Pointless data duplication with pointless silent compression, no idea what happened here.
Contributor guide
Assessment
This issue has not been assessed yet.